Yeah I tried that. it doesn't work.That's a sample program from some c++ site.I wrote this.
The file has two names and I want to read the 2nd one, so I used fin.seekg(20,ios::beg).. which makes it crash.If I remove it, it works fine , but reads the first name.
cout<<"\nPress 1 to write to the file, 2 to read.\n";
cout<<"\nEnter the name.\n";