//Compare strings using pointer
#include <stdio.h>
#include<string.h>
#define limit 100
void main()
{
int b,count=0;
char str[10],str1[10],*ch,*sh;
printf("ENTER FIRST STRING =\n");
scanf("%s",&str[0]);
printf("ENTER SECOND STRING =\n");
scanf("%s",&str1[0]);
b=strlen(str);
// ch=&str[6];
// printf("FIRST STRING = %s\n",str);
// printf("SECOND STRING =%s\n",str1);
/// printf("%d\n",(*ch));
for(int i=0;i<b;i++){
ch=&str[i];
sh=&str1[i];
if(*ch!=*sh){
// printf("STRING ARE NOT EQUAL");
count++;
break;
}
}
if(count==1){
printf("STRING ARE NOT EQUAL");
}
else{
printf("STRINGS ARE EQUAL");
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: