am trying to append to file but its not going correctly every time it fail to connect to file
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
fstream file;
char word[256];
file.open("StudentInfo.txt",ios::app);
//file.open("StudentInfo.txt",fstream::app); // wont work too
if(file.fail())
{
cout << " Error opening the file " << endl;
}
int i=0;
while(i < 3)
{
file.getline(word,256,'\n');
cout << word << endl;
i++;
}
return 0;
}
any advise
I can't use ifstream/ofstrem I have to use fstream advise please!
Thanks