/*To compare two strings using pointer.*/
#include
#include
main()
{
char a[10],b[10];
char *p,*q;
int i,j,status=0;
p=a;
q=b;
clrscr();
printf("\nInput two strings\n");
gets(a);
gets(b);
for(;*p!='\0' || *q!='\0';*p++,*q++)
if(*p!=*q)
{
printf("\nStrings are different");
status=1;
break;
}
if(status==0)
printf("\nStrings are same");
}
you does not use statement for -1.strcmp return -1 when string1 is less than string2.
ReplyDelete