File handling

the programme is not compiling &&& showing only a single error tht i culdn'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


#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");
}



u need a char*
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>//standard library is fstream not fstream.h
using namespace std;//good going

int main()//main should return a value
{
	fstream bfile; //fstream will take bOth if & of stream there4 b(both)file  
      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");//never ever use this again.. :O
}
return 0;
Last edited on
can u pLz explain in detail ................ @aramia
Also your code does not work.. try this
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
#include<iostream>
#include<fstream>
using namespace std;

int main()
{
	  fstream bfile; //fstream will take bOth if & of stream there4 b(both)file  
      char bchar;        //bchar charactrdecLared
      //open for writing
      bfile.open("bothh.txt",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.close();

      return 0;
}

not until you adress me corretly
@homi great buddddy it wOrked !!!!!thnxs a Lot.................;)
Please address it correctly.

http://www.partywithfestiveeffects.com/
you are welcome :)
Topic archived. No new replies allowed.