Compare two strings in C and C++

Bismillahir Rahmanir Rahim
Solution in C:

#include<stdio.h>
#include<string.h>
void main()
{
 char fs[50],ls[50];
 int jsl,msl;
 printf("Enter your first string. ");
 scanf("%s",fs);
 printf("Enter your second string. ");
 scanf("%s",ls);
 msl=strcmp(fs,ls);
 strcat(fs,ls);
 jsl=strlen(fs);
 if(msl==0)
  printf("The strings are equal.\n");
 else
  printf("The strings are not equal.\n");
 printf("Your joining string is= %s.\n",fs);
 printf("& reverce is= %s",strrev(fs));
 printf("And length is= %d.",jsl);
}
Solution in C++:

#include<iostream.h>
#include<string.h>
void main()
{
 char fs[50],ls[50];
 int jsl,msl;
 cout<<"Enter your first string. ";
 cin>>fs;
 cout<<"Enter your second string. ";
 cin>>ls;
 msl=strcmp(fs,ls);
 strcat(fs,ls);
 jsl=strlen(fs);
 if(msl==0)
  cout<<"The strings are equal.\n";
 else
  cout<<"The strings are not equal.\n";
 cout<<"Your joining string is= "<<fs<<endl;
 cout<<"& Reverce is="<<strrev(fs)<<endl;
 cout<<"And length is= "<<jsl<<endl;
}

Socializer Widget By Blogger Yard
SOCIALIZE IT →
FOLLOW US →
SHARE IT →