EXAMPLE CODE
Code:
#include<iostream>
#include<sys/stat.h>
#include<sys/types.h>
#include<fstream.h>
using namespace std;
main()
{
{
ofstream write ("home/p/code/gettester/test.txt");//writing to a file
if (write.is_open())
{
write << "This is a line."<<endl;
write << "This is another line."<<endl;
write.close();
}
else
cout << "Unable to open file";
}
string line;
ifstream read ("pathname/file.txt");//reading a file
if (read.is_open())
{
while (! read.eof() )
{
getline (read,line);
cout<<line<<endl;
}
read.close();
}
else
cout << "Unable to open file";
}
}


