Skip to main content
1 of 2
200_success
  • 144.2k
  • 22
  • 188
  • 473

You have the right idea in write_to_file(), but print_file() is awkward.

There is no need to work a character at a time in print_file(). You can read a line at a time using fgets(buffer, sizeof(buffer), in_file).

Avoid flag variables. Here, you could use a for loop to track the line number instead.

200_success
  • 144.2k
  • 22
  • 188
  • 473