APM Welcome, APM North West Network Conference, Synergies Across Sectors
String functions in C
1.
2. String Functions in C
Typing Speed: 25
Ismail
Ismailpk456@gmail.com
Ismail Ismu
Ismail Ismu
in.linkedin.com/in/profilena
me
8086303494
3. String Function
The standard library for C string functions
is string.h. This header file defines tons
of useful string manipulation functions
including
5. strcmp
• Strcmp() in C programming language is used
to compare two strings. If both the strings are
equal then it gives the result as zero but if not
then it gives the numeric difference between
the first non matching characters in the
strings.
6. strcat
• The strcat() function is used for string
concatenation in C programming language. It
means it joins the two strings together
7. strcpy
• strcpy function copies a string from a source
location to a destination location and provides
a null character to terminate the string.
8. strlen
The strlen( ) function is used to calculate the
length of the string. It means that it counts the
total number of characters present in the
string which includes alphabets, numbers, and
all special characters including blank spaces.
9. Strcmp
Syntax
int strcmp ( const char * str1, const char * str2 );
Example
int main()
{
char str1[30],str2[30];
printf("Enter first string: ");
scanf("%s",&str1);
printf("Enter second string: ");
scanf("%s",&str2);
if(strcmp(str1,str2)==0)
printf("Both strings are equal");
else printf("Strings are unequal");
return 0;
}
13. If this presentation helped you, please visit our
page facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
14. Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550