5 years 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

5 years 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);

oops the system seems to use <star> <star> to mean put the rest of the line in bold.

&d is of type char <star> <star> not type char

posted by Andy A 17 Nov 2014