• anonymous
Reading in line by line in C? I am having trouble with one programming problem: Write a complete program that reads in the player database of project 1 and prints out all the players who have made $6.0 millions or higher in the following format: Quarterback Donovan McNabb makes $12.00 millions - The file being read from is players.txt which is in the format like this 7869 QB Brees Drew 10.4 10 260. 3560 QB Brady Tom 9.6 11 240 The PROBLEM I am having is reading in these lines. I can attach my whole code, but the main section of my code is this: i=0; while(fscanf(players,"%d %c%c\n", &p
Computer Science
  • jamiebookeater
See more answers at
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly


Get your free account and access expert answers to this
and thousands of other questions

  • anonymous
i=0; while(fscanf(players,"%d %c%c\n", &playerID, &position[i], &position[i+1])){ printf("%d %c%c\n", playerID, position[i], position[i+1]); } //This only prints out 7869 QB I know this is very inefficient since you are reading in every character. So i tried to change the two %c%c to a string %s but i keep getting a segmentation error(core dumped). I read ppl using fgets and other stuff but I have to use fscanf etc I am lost and have no idea how to read in each line. I hope someone can help.Thanks!
  • anonymous
Are you sure, when you used "%s" instead of "%c%c" that you wrote "position" as parameter instead of "&position"?

Looking for something else?

Not the answer you are looking for? Search for more explanations.