Program to perform the operations on two strings using standard library functions.


C File =>



/* Write a program to perform the following operations on two
strings using standard library functions:
a. Copy        b. Compare       c. Calculate length */


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
int main()
 {
     char s1[50],s2[50],s3[50];
     printf("\n Enter String: ");
     scanf("%s",s1);
     printf("\n Length of string = %d",strlen(s1));
     strcpy(s3,s1);
     printf("\n Copied String is : %s",s3);
     printf("\n Enter String2 : ");
     scanf("%s",s2);
     if(strcmp(s1,s2)==0)
        printf("\n Entered strings are equal...");
     else
        printf("\n Entered strings are different..");
  return 0;
}

Comments

Popular posts from this blog

Write a program to allocate memory dynamically for n integers. Accept the elements and calculate their sum and average

C program to accept names of n cities and search for city named “Pune”.