Home >>C Tutorial >C Strings
The strings in the C language can be defined by various methods but the best definition is that it is basically a one-dimensional array of characters that is terminated by a null that is represented by the symbol (‘\0’). In order to manipulate the text that are basically the words or sentences, the strings or the character array is used. There are rules everywhere and in case of strings there is a rule that the last character always must be zero and one byte of memory is occupied by each character in the array. In order to identify where the strings is getting to the end, the use of the termination character ('\0') is then necessary in a string.
In order to declare the string there are two ways in the C language:
There are basically two known differences that are the main differences between the char array and literal.
Function | Description |
---|---|
strlen() | This function returns the length of the provided string. |
strcpy() | This function copies the source string in the destination. |
strcat() | The result is returned to first string after this function concatenates the two functions. |
strcmp() | This function compares the two strings and if both strings are equal then returns 0. |
strrev() | This function returns the reverse of the provided string. |
strlwr() | This function returns the characters of the strings in lowercase. |
strupr() | This function returns the characters of the strings in uppercase. |
strstr() | This function generally return the substring from first match till the last character. |