Articles added in Mathematics Lab | Cyber Lab is now open | Astronomy Lab is now open | VLSI Lab is now open | 120 SEO Tips article published | More exciting articles coming soon!

This header file contains declarations for some string manipulation functions.

1. strlen():
2. calculates the length of a string i.e. finding the number of characters in a given string(executing null char).

format:
n = strlen( a string); where n is an integer variable.

e.g. n= strlen(“HELLO”);
ouput:n=5

3. strcpy(s1,s2):
4. s1 and s2 are two strings,s2 will be copied into s1 i.e. s2 will be assigned to s1.

e.g. s1-> abc s2->def
strcpy(s1,s2);
s1->def s2->def

strcat(s1,s2): s1 and s2 are two strings,s2 will be added at the end of s1.There should be enough no. of locations remaining in s1 to add the characters of s2.

e.g. s1 -> GOOD s2-> DAY
strcat(s1,s2);
s1-> GOODDAY s2-> DAY

5. strcmp(s1,s2):
6. to compare s1 and s2.
Returns < 0 if s1 < s2
Returns = 0 if s1 = s2
Returns > 0 if s1 > s2
This function is case sensitive.

e.g. s1 -> abc s2 -> abc
strcmp(s1,s2) is 0, that means s1 and s2 are same.
s1 -> abc s2 -> acc
strcmp(s1,s2) returns < 0, that means s1 < s2.
s1 -> acc s2 -> abc
strcmp(s1,s2) returns > 0, that means s1 > s2.
s1 -> abc s2 -> ABC
strcmp(s1,s2) returns > 0, since ASCII value of a > A.

7. strcmpi(s1,s2):
8. same as strcmp(), but not case sensitive.
Returns < 0 if s1 < s2.
Returns = 0 if s1 = s2.
Returns > 0 if s1 > s2.

e.g. s1 -> abc s2 -> ABC
strcmpi(s1,s2) returns 0,that means s1 and s2 are same.

9. strrev(s1):
10. creates reverse of string s1 in s1 itself.

e.g. s1- > hello
strrev(s1);
s1 -> olleh

CACKLE comment system