Hi, i am trying to write a program that:
1) read an ascii formatted file into memory
2) modify the file slightly without changing the format and number of characters
3) output the changed data
heres the code:
ifstream infile("C:\\data.txt");
vector<xdcc> xdcc_array;
while(!infile.eof()) {
xdcc xdcc_read;
infile >> xdcc_read.name >> xdcc_read.packno >> xdcc_read.status;
xdcc_array.push_back(xdcc_read);
}
heres the format of the input file:
test 123 1
test 123 1
test 123 0
The program works by changing the boolean status from false(0) to true(1) when a particular line is processed.
However when there is an empty line at the very bottom of the input file, the program fails and the output text becomes meaningless. (The program works fine when there isn't an empty line though).
Is there any way to alter the code such that it skips the empty lines(if present)?
Thanks!