Why can't I input the integers from a file?

Posted by Anthony Glyadchenko on Stack Overflow See other posts from Stack Overflow or by Anthony Glyadchenko
Published on 2010-03-16T00:30:25Z Indexed on 2010/03/16 0:39 UTC
Read the original article Hit count: 411

Filed under:
|
|
|

I'm trying to get this C++ code to input a series of numbers from a text file:

    int x = 0;
    cin >> x;

    ifstream iffer;
    int numbers[12];
    iffer.open("input.txt");
    for (int i = 0; i < 12; i++){
        iffer >> numbers[i];
    }

This doesn't seem to work on the Mac. Every cell will equal to 0 regardless of the values in the text file. In other words, the ifstream isn't assigning the numbers.

How can I make this work? Is it a Mac issue and if so, how can I get it to work?

Thanks!

Anthony Glyadchenko

© Stack Overflow or respective owner

Related posts about mac

Related posts about input