C program to perform string manipulation functions

If you are using any software then below program will not give an error, but if you are using TURBO C then you have to make some changes like: void main() and some function like clrscr() or getch().

 int len1,len2;
 char str1[]="IMRT\0";
 char str2[]="INSTITUTE\0";

 printf("First string is %s\n",str1);
 printf("Second string is %s\n\n",str2);

 //Length of the string
 printf("Length of first string is : %d\n",len1);
 printf("Length of second string is : %d\n\n",len2);

 //Comparing both strings
  printf("Both strings are equal\n\n");
  printf("Both strings are not equal\n\n");

 //Concatenation of string
 printf("Concatenation of first & second string is %s\n\n",str1);

 //Reverse the strings
 printf("Reverse of first string is %s\n\n",str1);

 //printing strings
 printf("First string is %s\n",str1);
 printf("Second string is %s\n\n",str2);

 //Copying strings
 printf("Copied first string to second string %s",str2);


First string is IMRT
Second string is INSTITUTE

Length of first string is : 4
Length of second string is : 9

Both strings are not equal

Concatenation of first & second string is IMRTINSTITUTE

Reverse of first string is ETUTITSNITRMI

First string is ETUTITSNITRMI
Second string is INSTITUTE

Copied first string to second string ETUTITSNITRMI

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.