scanf, -Wall warning

Hi there,

using the following code:
char word[255];
// scanf("%254s", &word);
scanf("%s", &word);
// word[254]='\0';

I get a warning:
grammar.c:480: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[255]’

Even the reference example
http://www.cplusplus.com/reference/clibrary/cstdio/scanf/
should have this problem.
Is there a way to avoid this?

Cheers
Please try to use this:
 
scanf("%s", &word[0]);

or
 
scanf("%s", word);
Last edited on
perfect, thanks... how could I have done that...
you have to pass to scanf pointer.
Topic archived. No new replies allowed.