Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 5 months ago.
Error: Argument is incompatible with corresponding format string conversion
Hello Comunity,
I have a problem with my code. It works well, but i get every time an output warning:
- Argument is incompatible with corresponding format string conversion.
Anyone knows what is wrong with my string? Code:
--------------
...
float a;
int b, c;
char d[24];
...
sscanf(buffer,"%f%d%d%s", &a, &b, &c, &d);
...
-------------
The line for scanf looks like this: 0.111111 11 8 1111111111111111
Thank you.
1 Answer
9 years, 5 months ago.
Or the short answer, drop the & in front of d.
In C an array is just a pointer to a reserved block of memory so when you have a line
char d[24];
while d[n] is of type char d on it's own is of type char *
which means &d is of type char which is not what sscanf is looking for, it wants a char * which means
sscanf(buffer,"%f%d%d%s", &a, &b, &c, d);