Read ints recusively from file into array, the second last element always wrong : <pre><code>#include &lt;iostream&gt;
#include &lt;fstream&gt;
using namespace std;

int fillArray(ifstream&amp; ifs, int array[]){
    int cur;
    int counter = 0;

    if(ifs&gt;&gt;cur){
        counter = fillArray(ifs, array) + 1;
        array[counter-1] = cur;
    }

    return counter;
}



int main(int argc, const char * argv[]) {

    int count;
    int array[] = {0};
    ifstream myfile ("/Users/Desktop/example.txt");


    count = fillArray(myfile, array);

    for (int i = 0; i&lt;count; i++){
        cout&lt;&lt;array[i]&lt;&lt;endl;
    }

    myfile.close();

    return 0;
}
</code></pre>

<p>For example, if the input file is "1 2 3 100 19 16 33", the resulted array is "33 7 19 100 3 2 1".
if the input file is"1 2 3 4 5", the array will be "5 5 3 2 1". 
I don't mind ints are filled in reversely, but I don't understand what happened to the second last ints. </p>

<p>And this code works fine in VS, it only has problem in xcode. </p>
