█Mike█
23 Jun 2007, 04:57am
Hello guys, I'm trying to remove duplicate strings in a text file. I just need some guidance. The first is would it be better to use nested while loops?: while(!data_input.eof)
I have tried using nested for loops such as
<P> for(int current_line=0;current_line<start_number_lines;current_line++)
<br>{
<br>get line from text
<br>for(int check_line=(current_line+1);current_line<start_number_lines;check_line++)
<br>{
<br>get line from text
<br>check if both are same
<br>}
<br>if they the same
<br>{
<br>data_output<<current_line;
<br>}
<br>} </P>
Also please ignore the <"P"> i couldn't get it to write the code down.
But nothing has been working for me. I don't think i should nest the while loops, and when i count number of lines using a function that runs through the lines of the text file, every where else the file is referenced for input, it starts at eof so im getting blank lines. I really know I have to use buffers, but not clear on how to call each line back from the buffer, wouldn't it be a lot of pointers?
Thanks in advance,
Mike
I have tried using nested for loops such as
<P> for(int current_line=0;current_line<start_number_lines;current_line++)
<br>{
<br>get line from text
<br>for(int check_line=(current_line+1);current_line<start_number_lines;check_line++)
<br>{
<br>get line from text
<br>check if both are same
<br>}
<br>if they the same
<br>{
<br>data_output<<current_line;
<br>}
<br>} </P>
Also please ignore the <"P"> i couldn't get it to write the code down.
But nothing has been working for me. I don't think i should nest the while loops, and when i count number of lines using a function that runs through the lines of the text file, every where else the file is referenced for input, it starts at eof so im getting blank lines. I really know I have to use buffers, but not clear on how to call each line back from the buffer, wouldn't it be a lot of pointers?
Thanks in advance,
Mike