I am trying to use scanf() with strcmp. However, it doesn't work. I've included the right header files. I've tried out gets(). It works but I don't want to be vulnerable of a buffer overflow attack.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main() {
char a[100] = "Hello World!";
char b[100];
scanf("%s", &b);
if(strcmp(a, b) == 0) {
printf("This should work!\n");
}
}
I compile the program. Then, type Hello World! into the program. It won't show the message. Also, why does strcmp() show me all kinds of return values?
Please help.