Your SlideShare is downloading. ×
String functions in C
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

String functions in C

439
views

Published on

String functions in C

String functions in C


0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
439
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
71
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. String Functions in C Typing Speed: 25 Ismail Ismailpk456@gmail.com Ismail Ismu Ismail Ismu in.linkedin.com/in/profilena me 8086303494
  • 2. String Function The standard library for C string functions is string.h. This header file defines tons of useful string manipulation functions including
  • 3. String Functions  strcmp  strcat  strcpy  strlen
  • 4. 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.
  • 5. strcat • The strcat() function is used for string concatenation in C programming language. It means it joins the two strings together
  • 6. strcpy • strcpy function copies a string from a source location to a destination location and provides a null character to terminate the string.
  • 7. 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.
  • 8. 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; }
  • 9. Strcat Syntax strcat(first_string,second_string); Example int main() { char str1[30]="www.cprogramming"; char str2[15]="expert.com"; printf("nn string 1 : %stt string 2 : %snn",str1,str2); printf("nn strcat(str1,str2) : %snn", strcat(str1,str2)); getch();
  • 10. Strcpy Syntax strcpy(destination,source); Example int main() { char a[10],b[10]; printf("Enter string: "); scanf("%s",&a); strcpy(b,a); printf("Copied string: "); printf("%s",b); return 0; }
  • 11. Strlen Syntax temp_variable = strlen(string_name); Example int main() { char a[20]; printf("Enter string: "); scanf("%s",&a); printf("Length of string =%d n",strlen(a)); }
  • 12. 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
  • 13. 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
  • 14. THE END