Hi,
I have a question. I know how to read text files using ifstream. Now I would like to append some data at the end of the file.
I read a text file as follows:
#include "stdafx.h"
#include<string >
#include<iostre am>
#include<fstrea m>
using namespace std;
void main()
{
string line;
ifstream test_file;
test_file.open( "test.txt", ios::in);
if(test_file.is _open())
{
while(!test_fil e.eof())
{
getline(test_fi le, line);
cout<<line<<end l;
}
}
}
Now I would like to append some more data to the end of the text file. The data are numbers(int).
How can I do that.
Please Help.
Thanks!!
I have a question. I know how to read text files using ifstream. Now I would like to append some data at the end of the file.
I read a text file as follows:
#include "stdafx.h"
#include<string >
#include<iostre am>
#include<fstrea m>
using namespace std;
void main()
{
string line;
ifstream test_file;
test_file.open( "test.txt", ios::in);
if(test_file.is _open())
{
while(!test_fil e.eof())
{
getline(test_fi le, line);
cout<<line<<end l;
}
}
}
Now I would like to append some more data to the end of the text file. The data are numbers(int).
How can I do that.
Please Help.
Thanks!!
Comment