file handling

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)'

the code of the programme is :


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46



#include<iostream>
#include<fstream.h>
using namespace 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");
}





Last edited on
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 !!!!!
DUDE all x.h headers in c++ are just x so fstream.h is just fstream
stilll nOt working .......:(
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<iostream>
#include<fstream>
using namespace 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.
i m using dev c++ !!!!!but the cOde stilll didnOt wOrked
Last edited on
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)
0'shit !!!thnxs mAn ................. :)@aramila !!!!
Topic archived. No new replies allowed.