You messed up the format. (I assume the " was a typo)
try sscanf(mystring, "Name: %[^,], Age: %d, Weight: %f", name, &age, &weight);
Last edited on
Yes it was a typo but only here...
I think it should be like this
1 2 3 4
|
char name[10];
int age;
double weight;
sscanf(mystring, "Name: %[^,], Age: %d%[^,], Weight: %f", name, &age, &weight);
|
Output In both cases is:
Boy I am slim!
----
Edit: Ah, ah, sir! For testing I modifed
age to be a
double, gave me an unexpected input too...
Hope this helps solving the problem.
Last edited on