Use fgets to read a line of input and sscanf to parse that line. Then read the documentation on sscanf (scanf(3): input format conversion - Linux man page), especially the part about "return value"....