question about sscanf
Posted on 2006-04-30
Currently i have a method with code like this:
sscanf(s, "%lf %lf %lf %lf %d %d ", &x, &y, &z, &weight, &se, &sl); --- m1
this will read in the info about some 3D pionts from a file 'output'.
Now i am going to add one more property of the 3D points called 'name' and 'name' will be written to the 'output' file, so i changed the code to this:
sscanf(s, "%lf %lf %lf %lf %d %d %s", &x, &y, &z, &weight, &se, &sl, &name); -- m2
The problem happens because not all 'output' files have 'name' saved. I want to add some checking: if there is a 'name', use m2 otherwise use m1.
Could anyone give me some idea how to add such a checking? How do i check 'name' exists?