Thursday, 16 February 2012

Program to check whether two strings are same or not


#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i=0,k=0;
char n[100],m[100];
clrscr();
printf("Input the string:");
gets(n);
gets(m);
while(n[i]!='\0')
{
i++;
}
k=i;
i=0;
while(n[i]!='\0')
{
if(n[i]==m[i])
{
i++;
if(k==i)
printf("The two strings are same.");
continue;
}
else
{
printf("String are not same.");
goto p;
}
}
p:
getch();
}

No comments:

Post a Comment