This presentation covers string handling functions in C including declaring and initializing string variables, reading and writing strings, and functions like strlen(), strcat(), strcmp(), strcpy(), strupr(), strlwr(), and strrev(). It includes examples of programs that demonstrate how to use each string function without it and the benefits of the functions.
This presentation covers string handling functions in C including declaring and initializing string variables, reading and writing strings, and functions like strlen(), strcat(), strcmp(), strcpy(), strupr(), strlwr(), and strrev(). It includes examples of programs that demonstrate how to use each string function without it and the benefits of the functions.
This presentation covers string handling functions in C including declaring and initializing string variables, reading and writing strings, and functions like strlen(), strcat(), strcmp(), strcpy(), strupr(), strlwr(), and strrev(). It includes examples of programs that demonstrate how to use each string function without it and the benefits of the functions.
• Declare and initializing string variables • Reading and writing strings • String handling functions • programs Handling of character strings Declaring and initializing string variables Reading and writing strings Program String handling functions strlen() Program Without strlen() #include <stdio.h> int main() { char s[1000]; int c = 0; printf("Input a string\n"); gets(s); while (s[c] != '\0') c++; printf("Length of the string: %d\n", c); return 0; } strcat() Program Without strcat() #include <stdio.h> int main() { char str1[50], str2[50]; int i, j; printf("\nEnter first string: "); scanf("%s",str1); // hello\0 printf("\nEnter second string: "); scanf("%s",str2); // world\0
for(i=0; str1[i]!='\0'; i++); //i=5
for(j=0; str2[j]!='\0'; j++) { str1[i]=str2[j]; i++; //i=6,7,8,9,10 } printf("\n i value is : %d",i); printf("\n j value is : %d",j); //str1 = helloworld\0 str1[i]='\0'; printf("\nOutput: %s",str1);
return 0; } strcmp() Program strcpy() Program strupr(), strlwr(), strrev() Program