The document discusses four string functions: strlen returns the length of a string, strcpy copies one string to another, strcmp compares two strings and returns 0 if they match or other values if not, and strcat concatenates two strings.
The document discusses four string functions: strlen returns the length of a string, strcpy copies one string to another, strcmp compares two strings and returns 0 if they match or other values if not, and strcat concatenates two strings.
All the function discussed below exists in string.h header file
1. Strlen :- this function returns the length of the given string. syntax strlen(s1) :- where s1 is string type parameter e.g. Char name[10]=“bombay”; printf(“%d”, strlen(name)); 2. Strcpy :- this function copies the contents of one string to the other. syntax strcpy(s1,s2) this function will copy s2 string to s1 string e.g. char first[20]; char second[20]=“university”; strcpy(first,second); printf(“ \n %s “, first); String functions All the function discussed below exists in string.h header file 3. Strcmp : this function compares two strings and returns an integer value. If both the strings match then this function will return zero. syntax strcmp(s1,s2) : this function compares the strings and if match completely then will return 0 other wise if s1< s2 then will return value less than zero ohterwise if s1 is greater than s2 then will return value greater than zero. e.g. char a[10]=“kello”; char b[10]=“hello”; int value; value = strcmp(a,b); printf(“%d”, value); String functions All the function discussed below exists in string.h header file 4. Strcat : this function will concatenate or appends second string to the first string. syntax : strcat(s1,s2) : this function will append the second string to the first string. e.g. Char a[20]=“delhi”; char b[10]=“city”; strcat(a,” “); strcat(a,b); printf(“%s”, a);