How to write a C++ Program to check if two strings are identical or not in C++ Programming ?
C++ Program to check if two strings are identical. |
Solution:
//Program to check if two strings are identical.
#include<conio.h>
#include<iostream.h>
#include<stdio.h>
#include<string.h>
int main()
{
clrscr();
char a[80],b[80];
int z=0;
cout<<"Enter a string: ";
gets(a);
cout<<"Enter another string: ";
gets(b);
if(strlen(a)!=strlen(b))
cout<<"The strings are not identical.";
for(int i=0;a[i]!='\0';i++)
if(a[i]==b[i])
++z;
if(z==strlen(a))
cout<<"The strings are identical.";
else
cout<<"The strings are not identical.";
getch();
}
This C++ Program to check if two strings are identical.