%s
format string accepts argument of type char*
where as &intput
is of type char (*)[10]
that is the reason you are getting warning.
format '%s' expects type 'char *', but argument 2 has type 'char (*)[10]
Note argument 2
is &input
in scanf()
scanf("%s", &input);
^ ^
| argument-2
argument-1
To correct this code you should write scanf like:
scanf("%s", input);
Side note:: value wise both &input
and input
are same if you string address but semantically both are diffrent.
&input
is address of array that is char(*) [10]
type whereas input
type is char[10]
To understand difference between &input
and input
read this two answers:
- What does sizeof(&arr) returns? , and
- Issue with pointer to character array C++
Edit:
Changing to: char *input
will not help you instead it becomes undefined behavoiur unless and until you allocated memory to input