sahajjain01

Check if two strings are identical.

Sep 13th, 2013
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. //Program to check if two strings are identical.
  2. #include<conio.h>
  3. #include<iostream.h>
  4. #include<stdio.h>
  5. #include<string.h>
  6.  
  7. int main()
  8. {
  9.     clrscr();
  10.     char a[80],b[80];
  11.     int z=0;
  12.     cout<<"Enter a string: ";
  13.     gets(a);
  14.     cout<<"Enter another string: ";
  15.     gets(b);
  16.     if(strlen(a)!=strlen(b))
  17.     cout<<"The strings are not identical.";
  18.     for(int i=0;a[i]!='\0';i++)
  19.     if(a[i]==b[i])
  20.     ++z;
  21.     if(z==strlen(a))
  22.     cout<<"The strings are identical.";
  23.     else
  24.     cout<<"The strings are not identical.";
  25.     getch();
  26. }
Advertisement
Add Comment
Please, Sign In to add comment