Originally Posted by
but
thanks a lot - pls explain the point of this line -
printf("bad line: j=%d i=%d\n[%s]\n", j, i, line); return EXIT_FAILURE;
Code:
if (sscanf(line, "%*f %*f %lf %lf %lf", &x, &y, &z) != 3) {
printf("bad line: j=%d i=%d\n[%s]\n", j, i, line);
return EXIT_FAILURE;
}
If sscanf returns 3 it means that it properly read 3 fields. If it doesn't return 3 then something went wrong, so I print an error message and exit. EXIT_FAILURE is just a macro that's equal to a non-zero value appropriate for indicating failure on the system. It's equal to 1 on linux.