String in C programming

String

The collection of characters is called a string.

Declaration & initialisation of a string

char name[100]="capscom";

strlen

Return length of a string

strlen(string)

strcpy

Copy one string into other string

strcpy(str1, str2)

strcat

Concat one string with other string

strcat(str1, str2)

strcmp

Compare two string and return

  • -1 if string1 is smaller than string2
  • 0 if string1 is same as string2
  • 1 if string1 is greater than string2
strcmp(str1, str2)
© 2016 - 2022, All Rights are Reserved.