www.digitalmars.com         C & C++   DMDScript  

c++ - Many errors while compiling. Please help.

reply Artur <eternal.beast gmail.com> writes:
#include <iostream>
#include <iostream>
using namespace std;


int main()
{
	int n[5]={1,2,3,4,5};
	register int i;

	ofstream out("test", ios::out | ios::binary);
	if(!out){
		cout << "Not able to open file.\n";
		return 1;
	}

	out.write((char *) &n, sizeof n);

	out.close();

	for(i=0;i<5;i++)// clearing array
	n[i]=0;

	ifstream in("test", ios::in | ios::binary);
	if(!in) {
		cout <<"Not able to open file. \n";
		return 1;

	}

	in.read((char *) &n, sizeof n);

	for(i=0;i<5;i++)// showing value, which are rode from file.
	cout << n[i] << " ";

	in.close();

	return 0;
Nov 05 2008
parent reply Bertel Brander <bertel post4.tele.dk> writes:
Artur skrev:
 #include <iostream>
 #include <iostream>
The second one should be: #include <fstream>
 	return 0;
I miss a } here With the above changes, it should compile, if not, tell us what the compiler tells you.
Nov 05 2008
parent Artur <eternal.beast gmail.com> writes:
I tried so hard but I must have been blind...
It works!
Thanks.
Nov 06 2008