Newbie here, right so I'm trying to get some integers from a text file and store them in a array. I have not been very successful as I keep on getting errors. I am not very good with arrays. I want to know what I'm doing wrong and how should I fix it.So in my text file I have 9 integers and Im trying to store it in the array. In the main File im trying to output one number in my array.
Might be a copy and paste error but line 1 you forgot the '#' symbol.
you declare a const char* with 9 elements, lets count how many you declare:
1(N) 2(u) 2(m) 3(b) 4(e) 5(r) 6(s) 7(.) 8(t) 9(x) 10(t)
another way of writing constchar INPUT_FILE[9] is constchar * INPUT_FILE which is a pointer to char(array).
when opening the file you never used the const char array you set up, there is no reason to have the variable there.
You can open the file during the constructor to save time ifstream inFile("numbers.txt")
what happens if the text file contains 15 numbers? the array bounds would cause your program to crash. You need to use a for loop to read in number x(arr length) times.