0
1.6kviews
State any 2 library function in string.h along with its uses.
1 Answer
0
3views

I) Strcat(string1, string2):

String1 and string2 are character arrays. The string2 is appended to the end of string1. Replace the null character at the end of string1 with string2 from there does it. The string2 remains unchanged.

Example:

Char string1[20] = “John”, string2[10] = “Terry”;
Strcat(string1, string2);
After execution of the strcat() function, the content of string1 is “JohnTerry”.

II) Strncpy:

The strncpy() function is similar to strcpy(), except that strncpy() lets you specify how many characters to copy.

Example:

char str1[10], str2[10];
char * strncpy (char *destination, char *source, size_t n);
strncpy(str2, str1, 5);
Please log in to add an answer.