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
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
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
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;