Both Ate and App makes the file pointer points to the end of file,but there is a difference in these two.
That during App mode we cannot change the position of pointer using seekg i.e "No Modify"
While in Ate mode we can change the position of pointer using seekg i.e "Modify Allowed".
Following Program Illustrates the concept:
#include<iostream>
#include<fstream>
using namespace std;
main()
{ int a;
fstream file("file.txt",ios::in|ios::out|ios::app);
fstream file2("file2.txt",ios::in|ios::out|ios::ate);
file<<1507;
file2<<1507;
file.seekg(0,ios::beg);
file2.seekg(0,ios::beg);
file<<623;
file2<<623;
file.close();
file2.close();
}
Special Thanks To Miss Naina Thaman For This Program.
File Output:
file.txt: file2.txt:
That during App mode we cannot change the position of pointer using seekg i.e "No Modify"
While in Ate mode we can change the position of pointer using seekg i.e "Modify Allowed".
Following Program Illustrates the concept:
#include<iostream>
#include<fstream>
using namespace std;
main()
{ int a;
fstream file("file.txt",ios::in|ios::out|ios::app);
fstream file2("file2.txt",ios::in|ios::out|ios::ate);
file<<1507;
file2<<1507;
file.seekg(0,ios::beg);
file2.seekg(0,ios::beg);
file<<623;
file2<<623;
file.close();
file2.close();
}
Special Thanks To Miss Naina Thaman For This Program.
File Output:
file.txt: file2.txt:
1 comments so far
Nice