reading data from a file into a array

closed account (17MDjE8b)
i need someone to help explain how i would read 40 numbers from a file into the array in the order they are read in. Im not good with arrays however i do know how to read data from a file normally. please help
you'll have to use while statement like so:
1
2
3
ifstream file("/file");
int* arr[40], i = -1;
while(file >> arr[++i]);

just make shore that size of the array is big enough!
Last edited on
Topic archived. No new replies allowed.