I'm having trouble getting the list of 1000 numbers into an array from a file. Whenever I run the program, it shows that a bunch of zeros are entered into the array.
#include <iostream>
#include <fstream>
usingnamespace std;
#define size_of_array 1000
int holdNumbers[size_of_array];
void inputNumbers();
int main() {
inputNumbers();
for (int i = 0; i < 10; i++){
cout << holdNumbers[i]; //print first 10 numbers to check if
} //reading numbers into array is sucessful
return 0;
}
void inputNumbers() {
ifstream inText("ProblemNumbers.txt");
inText.open("ProblemNumbers.txt");
for (int i = 0; i < size_of_array; i++){
inText >> holdNumbers[i]; //grab character and put into array
}
inText.close(); //close file
}
The file "ProblemNumbers.txt" is in the same folder as my source code and i just copied and pasted the numbers from the site so they look like this (if it matters).