Hello guys i need some help,
i need a program to read a text file. I write this:

#include <iostream.h>
#include <fstream.h>
#include <cstring.h>
void main () {
int is_open;
  string line;
  ifstream myfile;
  myfile.open ("a.txt");
  if (myfile.is_open())
	 while (! myfile.eof() )
		getline (myfile,line);
		cout << line << endl;

  else cout << "Unable to open file";


and now i have a error " 'is_open' is not a member of 'ifstream' in function main()"

Edited 6 Years Ago by Dex02: n/a

You have to make a file buffer and use file descriptor such as:

 int fd;
 fd=open("d:\\or.txt",O_RDWR | O_CREAT);
 filebuf iofile(fd);

   cerr<<"The filebuf is not open ";

 iofile.sputn("KaVi International", 21);

As you see when you use is_open it corresponds to file buffer and thus it would show you error of not supported type if you not use it with file buffer. Try this

Edited 2 Years Ago by Dani: Formatting fixed

This is simple.. try this...

void main()
 ofstream f1;
   f1<<"Hello Senthil";
   cout<<"Data written successfully!";
This article has been dead for over six months. Start a new discussion instead.