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()"

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

This is simple.. try this...

void main()
 ofstream f1;
   f1<<"Hello Senthil";
   cout<<"Data written successfully!";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.