|
|
while ( yourfile.good() )
is bad.
|
|
// changed
|
|
C:\Temp>testxxx3 File open Line#1 String first found at position 1 Line#2 String first found at position 9 |
|
|
C:\Temp>testxxx4 String: GETGGGGGGGGGATGGGGGGATETGGAEGETAEEEEGETEEAEEEAEAEEEAGGAGGATAEAGATAEAGAGA EATAGGAEATAGAGTAGAAGAGGAGA Line#1 String found at position 1 Line#1 String found at position 29 Line#1 String found at position 37 ------- String: AGAEAEEAGETGGAGAGGAAGETGAGAGGAGAGAGETGAGAGAGGAGAGAGGAGAGAGGETAGAGAGGAGAG GAGAGAEGAGAGGAGAGAGGETGAGAGAGGGETETTTTTTETAGGGET Line#2 String found at position 9 Line#2 String found at position 21 Line#2 String found at position 35 Line#2 String found at position 59 Line#2 String found at position 92 Line#2 String found at position 103 Line#2 String found at position 118 ------- |
while ( yourfile.good() )
if( !std::getline( yourfile, u_file ) ) break ;
|
|
Another effective technique is to explain your code to someone else. This will often cause you to explain the bug to yourself. Sometimes it takes no more than a few sentences, followed by an embarrassed "Never mind, I see what's wrong. Sorry to bother you." This works remarkably well; you can even use non-programmers as listeners. One university computer center kept a teddy bear near the help desk. Students with mysterious bugs were required to explain them to the bear before they could speak to a human counselor. - Brian W. Kernighan and Rob Pike in 'The Practice of Programming' |
|
|
Another effective technique is to explain your code to someone else. This will often cause you to explain the bug to yourself. Sometimes it takes no more than a few sentences, followed by an embarrassed "Never mind, I see what's wrong. Sorry to bother you." This works remarkably well; you can even use non-programmers as listeners. One university computer center kept a teddy bear near the help desk. Students with mysterious bugs were required to explain them to the bear before they could speak to a human counselor. - Brian W. Kernighan and Rob Pike in 'The Practice of Programming' |
|
|
|
|