Hey everyone. Im using a 'file.getline' to grab a line of text from a file and write it into another file. The problem is that it wont grab the full line in the file. Here is some code: (outline and i_outline are 2 files streams created with ifstream and ofstream)
char param1[256]={0}; //the parameter that holds the text
char quote='"'; //used to write in quotes
output<<"blah "<<quote;
for(i=0;i<i2;i++)
{
output<<param1[i];
}
output<<quote<<"blah"<<endl;
This is where its written to the file, then later we want to transfer it to another file:
char *file_line=new char[256];
while(i_output.eof()==false) //loop while the file isn't done
{
i_output.getline(file_line,256); //grab a line
o_main<<file_line<<endl; //output it to the other file
}
Now, what I want this code to do, is say that 'param1' held the text 'hello', then it should write to the first file: "blah"hello"blah"
but all it writes is blah". Now, I thought that getline will read a while line in a file until it reaches '\n' (by default). When I wrote to the first file, I didnt use 'endl' until the final "blah", so I dont see why it isn't writing the whole line. Anyone know? Thanks
http://www.labino.net -
freeware and shareware games.
Edited by - dirkduck on March 24, 2002 7:54:55 PM
Edited by - dirkduck on March 24, 2002 7:55:50 PM
Edited by - dirkduck on March 24, 2002 7:56:41 PM
Edited by - dirkduck on March 24, 2002 7:57:22 PM