My little program does not work

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include<iostream>
#include<fstream>
#include<iterator>
#include<algorithm>
#include<list>

using namespace std;

int main()
{
list<int> foo;
ifstream infile("c:\\a.txt");
istream_iterator<int> in(infile);

copy(in,istream_iterator<int>(),front_inserter(foo));
copy(foo.begin(),foo.end(),ostream_iterator<int>(cout," "));
cout<<endl;

system("pause");
}


The purpose of this program is to read the data from a.txt and insert into the link "foo", then print the result on the screen with a blankspace in between them. There was nothing showing up in the screen. Can i ask what is wrong? Thanks.
Is there anything in the list foo?

Learning to debug your own program is part of the task too.
Topic archived. No new replies allowed.