I am having following code for reading and writing from an file....
but when i directly read from file... it displays all the data..
but when i do some write and the again read then it does not read any thing..
getline returns without reading anything...
and then file reaches to eof...
int main()
{
fstream tempFile;
tempFile.open( "abc.txt" );
if( !tempFile.is_open() )
{
printf("ERROR: Enable to Open File ");
exit(0);
}
printf("Writting To file\n");
string buffer = "I am in File";
tempFile.write ( buffer.c_str(), buffer.size( ) );
tempFile.write ( "\n", 1 );