Your main problem is simply that it's poorly written code. For one, void main is NOT valid C++. For another, you don't initialise your variable, and for a third, you don't check to see if you've succeeded in opening a file, which you give only a relative path to.
int main()
{
int array = -1;
ifstream infile ("c:\binga");
if (infile.isopen())
{
infile >> array;
cout << array << endl;
}
else
cout << "Unable to open file";
}
I think you'll find it cannot open/find the file and is giving you the initial value of array. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?! - Jon Hulatt, 22/3/2002