read data from notepad without fstream

Hi guys.
Anyone know how to read data from notepad or other .txt files without using the #include <fstream> header??
I'm supposed to read a data from a notepad file, but i only allowed to use #include <iostream>
Thanks. :)
Last edited on
Reference for the iostream library can be found here:
http://cplusplus.com/reference/iostream/
http://cplusplus.com/reference/iostream/iostream/

Also notice that iostream is actually one of the base classes for fstream. I would think this problem would require you to write your own definition of fstream using the iostream library.
Last edited on
thanks for the reference. but i'm still not too clear about it.
sorry about that. i'm a begginer in this c++.
can you give me one example? just a simple one. thanks :)
Actually it's pretty simple. Your program may read text from the standard input (std::cin). You only need to redirect this standard input to a file when executing the program. For example, under Windows:

program.exe < file.txt
thanks for that, Abramus.
but the problem is that method haven't been taught.
and my teacher don't allow me to use the method which haven't taught by him.
is there another way? another simpe one.

hmm. let me show you the header file if you can find out another solution. thanks. :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
using namespace std;
const int MAX = 20;

class Customer
{
	friend ostream& operator<< (ostream&, Customer&);
	
	public:
		Customer ();
		Customer (char [], char);
		Customer (const Customer&);
		
		char getSex () const;
		Customer& operator= (const Customer&);
		
	private:
		char name [MAX];
		char sex;
};


i don't allowed to add more header or function inside.
that's what make me confuse.
Topic archived. No new replies allowed.