I had written a program

#include <fstream.h>
void main()
{
fstream f;
f.open("test.txt",ios::app|ios::in|ios::binary);
cout<<f.tellg();
f.close();
}

My file test.txt already contains text : " hello " i.e. 5 characters
But when i try this it outputs only 0 but ios::app mode places the pointer at the end of file so why it is not showing 5 instead of 0.

ios::app places the pointer at the end of the file whenever you try to write to a file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.