another newbie question

Wilson GV (gvw@cs.vu.nl)
Sun, 14 Aug 1994 10:41:31 GMT

What is the simplest safe equivalent of C's scanf? I want to read a
file containing complex numbers of the form (a, b), and store the "a"
and "b" values in structure fields:

i = 0;
while (fgets(buf, Buf_Len, infile) != NULL){
ass(buf[0] = '(', "badly-formatted input line",
"line", "%d", i, NULL);
ass(sscanf(buf+1, "%f%f", &(c[i].r), &(c[i].i)) == 2,
"badly-formatted input line",
"line", "%d", i, NULL);
i++;
}

I know I can do this with readline(), split(), and atof(), but it
requires a lot of extra lines of error checking (or seems to).

======================================================
Gregory V. Wilson gvw@cs.vu.nl
Beg, starve, rebel... Beg, starve, rebel...
We are not such a people
- Alasdair Gray
======================================================