Null terminated or C strings: String manipulation functions: strcpy, strcat, strcmp, strlen, strchr, strstr

A null terminated string is actually a null terminated character array. Here’s how to declare null character string:

char str[20];

This string can hold up to 19 characters. The last string is the null string. While using a string constant, we actually use the null terminated string. A list of characters enclosed in double quotes is known as string constant.

String manipulation functions:

Name of Function Action
strcpy(a1, a2) Copies a2 into a1.
strcat(a1, a2) Concatenates a2 onto the end of a1.
strcmp(a1, a2)  Returns 0 if a1 and a2 are the same; less than 0 if a1<a2;greater than 0 if a1>a2.
strlen(a1) Returns the length of a1
strchr(a1, a2) Returns a pointer to the first occurrence of ch in a1.
strstr(a1, a2) Returns a pointer to the first occurrence of a2 in a1.

Leave a Reply