invisible.hippo
Arch-Supremacy Member
- Joined
- Nov 8, 2008
- Messages
- 17,902
- Reaction score
- 315
Hi, i am facing a issues of writing structure to file.
I am able to write a structure to file, however i need to have a "line number" for every line in the file.
I try to use a loop to do the line number using this method
for int i = 0; i < ???; i++
but my structure writen to the file is dynamic, meaning my structure is design to keep on writing this structure to the file until it is choosen not to.
What should i put for the "???" .?
if i write like this for int i=0; i<100;i++, then line number 101 will not appear for the 101 line written to the file.
Or do i have to write finish the structure to the file, close it. Follow by reading in line by line using ifstream to get the number of line in the file and then open the file again and write the number of line?
Thank you
I am able to write a structure to file, however i need to have a "line number" for every line in the file.
I try to use a loop to do the line number using this method
for int i = 0; i < ???; i++
but my structure writen to the file is dynamic, meaning my structure is design to keep on writing this structure to the file until it is choosen not to.
What should i put for the "???" .?
if i write like this for int i=0; i<100;i++, then line number 101 will not appear for the 101 line written to the file.
Or do i have to write finish the structure to the file, close it. Follow by reading in line by line using ifstream to get the number of line in the file and then open the file again and write the number of line?
Thank you