I'm trying to read a string and print it in Linux using:
cc child.c -o child
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
char st[100];
scanf("%s", &st);
printf("%s", st);
return 0;
}
However I encounter this warning that will not allow me to compile.
child.c: In function ‘main’:
child.c:8:2: warning: format ‘%s’ expects argument of type ‘char ’, but argument 2 has type ‘char ()[100]’ [-Wformat=] scanf("%s", &st);
How can I solve it? Thanks!
scanf("%s", &st);toscanf("%s", st);)