I would use scanf for this. It has the advantage that it can tell you if a line is not properly formatted (OR if your format string is not specified correctly).

Example:


char buf[10000];...