how to sscanf multiple times

Hi

I have this string that has multi-line float values

and when i printf("%s\n", string)

it will show me

50.11
33.22
22.44

and so on

what I want to do is extract and print values by each line

I tried
1
2
3
4
5
6
7
8
9
char * pos;
float j;

pos = sscanf(string, "%f", &j);
while( pos != NULL)
{
   printf(" found = %f\n", pos-string+1);
   pos = sscanf(pos+1, "f", &j);
}


and i get various warnings saying
format %f expects type doulbe but argument has type int and
assignment makes pointer from integer without a cast


I tried this method by referring to http://www.cplusplus.com/reference/clibrary/cstring/strchr/

can anyone help me with this?
Last edited on
Topic archived. No new replies allowed.