#include <stdio.h>
#include <string.h>
int main() {
char str1[20];
char *str2;
printf("enter string \n"); **// using %c input**
scanf("%c",str1);
printf(" string 1 is %s \n",str1);
printf("enter string 2 \n");
scanf("%s",*str2); //using %s input
printf(" string 1 and 2 is %c and %s \n",str1,str2);**strong text**
int a=strcmp(str1,str2); //**comparing both**
printf("%d",a);
return 0;
}
took input from user using %c and %s then used strcmp for comparing the equality of the strings
Read more here: https://stackoverflow.com/questions/64949910/take-string-as-input-from-user-by-c-and-s-and-confirm-that-both-the-strings-ar
Content Attribution
This content was originally published by Rutvikk Walde at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.