cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
scanf, -Wall warning
scanf, -Wall warning
Feb 8, 2010 at 9:25am UTC
Solour
(2)
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
Feb 8, 2010 at 9:33am UTC
Denis
(350)
Please try to use this:
scanf(
"%s"
, &word[0]);
or
scanf(
"%s"
, word);
Last edited on
Feb 8, 2010 at 9:34am UTC
Feb 8, 2010 at 9:38am UTC
Solour
(2)
perfect, thanks... how could I have done that...
Feb 8, 2010 at 9:41am UTC
Denis
(350)
you have to pass to scanf pointer.
Topic archived. No new replies allowed.