I think you need in the while loop a conditional statement that compares the line you are getting from a file and a desired data( in your case is B345). Once you got that, print the next two lines and break the while loop.
Pseudo Code:
while ( reading from a file )
{
temp variable = get line from the file;
if ( desired data == temp )
{
print the desired data and the next two lines;
break;
}
}
is there any other way to juz add the statement into my current program codes? abit new to file & string chapters...and dun really understand ur codes ><
If you don't understand my code you might want to go back through some of the tutorials on this site.
Considering your code hoses random memory and you think comparing pointers is useful in this situation, perhaps he's not the only one that should be reviewing some material. =)
I would suggest storing the data in a container when getting it from the file, then manipulating the information int the container you have chosen, once done you just simply over-write the file with the
to keep it simple you can use a vector you know that all the data is stored as 3s so when you get a match you simply over write the data for the next two elements with the new.
else you can have a class and use even a map if you know how to. lots of flexible ways to do it. just go with the one that is easier for you.