This snippet opens a file and inputs the number of records stored at the start; but then after that you will see I repeat the fstream allocation (without closing the original) and everything works exactly as it should.
However if I take this repeat fstream statement out it then doesn't output anything to the file - this I don't understand and it just doesn't seem right - is it - can anyone explain this to me?
fstream jcfile ( filename);
if ( !jcfile.is_open() )
cout<<endl<<endl<<endl<<"The file could not be opened.";
cout<<endl<<endl<<endl<<"There are currently "<<numrecords<<" records in this file.";
fstream jcfile (filename);// why is this needed
jcfile<<"hello you sailor";