Hi
Basically i am trying to read a file and insert a specific string at a position. but it seems that the entire process freezes and the program runs out of control.

fstream shot;
char mess[240];
shot.open("file.vix");

while(!shot.eof())
{
shot.getline("mess",240);

if(strcmp(mess,"<DEPT>)==0)
{
shot<<"< ANNOUNCED >\n";  //TROUBLE
}
}

the code works fine until it encounters the <DEPT> tag and it comes to the next line. but at that position when i try to write the "< ANNOUNCED > "tag the program simply goes into a loop.
wont read anything, wont write anything, wont detect the end of file. the while loop simply goes on without any other reaction.

I HAVE CONFIRMED THIS BY GIVING COMMENT OUT PUT TO SEE THE
LOCATION OF CODE THAT IS RUNNING.

as this problem is not anything i can handle with the knowledge i have i am posting it here. please help me with this.
this is a verry important assignment , and i have to get it ready pretty soon.

Edited 6 Years Ago by blaisemcrowly: n/a

What you are attempting to do -- if it worked -- is corrupt your file by overwriting the next line of data with ANNOUNCED
You need to open a second file and after reading a line, write the line to the new file. Then do your test.

What you are attempting to do -- if it worked -- is corrupt your file by overwriting the next line of data with ANNOUNCED
You need to open a second file and after reading a line, write the line to the new file. Then do your test.

Thank you .. i will check it right away and let you know

This article has been dead for over six months. Start a new discussion instead.