It's a bit tricky. If you try to strcmp(line, targetName), then you will have the problem of fgets() adding in the newline at the end of the line, like it always does if it has room for it.
Which causes the strcmp() to always fail.
Study this:
Code:
while(fgets(line, sizeof(line),fp)) {
sscanf(line, "%s", name);
if((strcmp(target, name))==0) {
fgets(line, sizeof(line),fp);
sscanf(line, "%d %d",&num1, &num2);
fgets(line, sizeof(line), fp);
sscanf(line, "%d %d",&num3, &num4);
printf("%s's numbers are %d, %d, %d and %d\n",target,num1,num2,num3,num4);
}
}