fstream project

The program should write and than read it does not read so it can not write i don't understand whats the problem

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
 int main()
{
ofstream infile("Record.txt",ios::out|ios::binary);
char name[20];
int age;
for(int i=0 ; i<3; ++i)
{
	cout<<"Enter name\n";
	cin>>name;
	cout<<"Enter age\n";
	cin>>age;
	infile<<name<<age;
}
ifstream offile("Record.txt",ios::in|ios::binary);
for(int i=0; i<3;++i)
{
	cout<<"Name : ";
	offile>>name;
	cout<<name;
	cout<<endl;
	cout<<"Age : ";
	offile>>age;
	cout<<age;
	cout<<endl;
}
getch();
}
Topic archived. No new replies allowed.