the program is not compiling &&& showing only a single error that i couldn't understood.have seen the code many times but i couldn't found the error........ pLz heLp me !!!!!
the eror shOwing in compiler iz:
307 C:\Users\biLmLik\Desktop\fiLe hAndLing.cpp no matching function for call to `std::basic_fstream<char, std::char_traits<char> >::open(const char[10], bool)'
#include<iostream>
#include<fstream.h>
usingnamespace std;
fstream bfile; //fstream will take bOth if & of stream there4 b(both)file
main()
{
char bchar; //bchar charactrdecLared
//fiLe opened fOr bOth input &&& putput
bfile.open("bothh.txt",ios::in || ios::out);
if(!bfile) //errOr hAndLing
{
cout<<"errOr occured";
}
for(bchar='A';bchar<='Z';bchar++)//Loop run tO write aLphabats
{
bfile<<bchar; //inserting frOm bchar tO bfile
}
bfile.seekg(8l,ios::beg);//seeks 8th character $ mOve fOrward in a fiLe
bfile>>bchar; //
cout<<"the 8th aLphabet iz "<<bchar;
bfile.seekg(-16l,ios::end);
bfile>>bchar;
cout<<"the 8th aLphabet iz "<<bchar;
bfile.close();
system("pause");
}
After fixing "fstream.h" header (there is no such header in modern C++) and fixing declaration of main() by returning int (as standard c++ requires) the code compiles just fine in Visual Studio (other compiler may require include cstdlib too).
dude that fstream.h is a fiLe handling header.....bt after including int with main && cstdlib.h header file prOgram is still showing the same error !!!!!
#include<iostream>
#include<fstream>
usingnamespace std;
fstream bfile; //fstream will take bOth if & of stream there4 b(both)file
int main()
{
char bchar; //bchar charactrdecLared
//fiLe opened fOr bOth input &&& putput
bfile.open("bothh.txt",ios::in || ios::out);
if(!bfile) //errOr hAndLing
{
cout<<"errOr occured";
}
for(bchar='A';bchar<='Z';bchar++)//Loop run tO write aLphabats
{
bfile<<bchar; //inserting frOm bchar tO bfile
}
bfile.seekg(8l,ios::beg);//seeks 8th character $ mOve fOrward in a fiLe
bfile>>bchar; //
cout<<"the 8th aLphabet iz "<<bchar;
bfile.seekg(-16l,ios::end);
bfile>>bchar;
cout<<"the 8th aLphabet iz "<<bchar;
bfile.close();
//system("pause");
}
If this code does not work then try a modern compiler, not crap like Turbo C++ which you are probably using.
it wouldnt actually make a diffrence its just more of a syntax thing. why the hell did you post this twice dude. just start posting on the other one and stop on this one.
try this (its what i do):
1 2 3
#include <string>
string file = "
damn it... i just realized what was wrong... its ios::in | ios::out
(it might be ios_base)