0

I have been trying to read a file using fgetc but i am unable to break the line into the pieces that i require

ex if i have: x: xx xxx, xxxx; and i want to break that into:

x

xx

xxx

xxxx

user2785532
  • 53
  • 1
  • 6

2 Answers2

1

i would split the task into 2 parts. Read the line; break it apart. USe getline to read the line. There are several ways to break it up; strchr is probably yr best bet

pm100
  • 48,078
  • 23
  • 82
  • 145
0

If you keep using the character parsing method, you will need to do more string management on buffer to keep track of what you want to print. I don't see any reseting of num_chars after each match, nor any addition to the buffer to terminate the string prior to printing [code]buffer[num_chars] = 0;

Jon Brauer
  • 146
  • 3