Time to perform some operations on strings 😃
Make sure to include the string.h file on the top.
Compute String Length
The strlen() function calculates the length of a given string.
Length of name is : 7
Note that the data type of variable l is int (to measure the length).
Convert a String to Lowercase
The strlwr() function converts the string to lowercase.
BTS turned to bts
Convert a String to Uppercase
The strupr() function converts the string to uppercase.
ANIME is my besto frendo!
Copy a String to another
Function : strcpy()
Tom Holland and Tom Hiddleston
Concatenate (Join) Strings
In C programming, the strcat() function concatenates (joins) two strings.
Programatrix will always be there for you :)
Compare Two Strings
The strcmp() compares two strings character by character.
If the strings are equal, the function returns 0.
The possible values of strcmp() are 0, 1 and -1.
0
1
-1
It returns 1 when the first non-matching character in str1 is greater (in ASCII) than that of str2.
And it returns -1 when the first non-matching character in str1 is lower (in ASCII) than that of str2.
Reverse a String
Function : strrev()
I am sad :(
Hope you enjoyed this blog.
Jeez! That was worth exploring 😃
Have any doubt ?
DM me on Instagram
Peace ✌️