this question bothers me this few days.
I want to read a string for example, input = (-0.001999,-0.919191,-0.777777,999999.999999)
using sscanf. And my code is
char x[10], y[10], z[10], angle[10];
sscanf( input+1, "%[^,],%[^,],%[^,],%[^)]", &x, %y, &z, &angle);
printf("%s %s %s %s\n", x, y, z, angle);
the expected result is x=-0.001999 y=-0.919191 z=-0.777777 a=999999.999999
but my printf shows : x=-0.001999 y=-0.919191 z=999 a=999999.999999
can somebody help me figure out where the problem is ??
thx!
angle is not big enough to hold the input data and thus z is getting overwritten. Try this: