How can I read integers from a file into an array of integers in C ++? So, for example, this is the contents of the file:
23 31 41 23
will become:
int *arr = {23, 31, 41, 23};
?
I actually have two problems. Firstly, I do not know how I can read them line by line. For one, it would be pretty easy, just the syntax file_handler >> number could do it. How to do this line by line?
The second problem, which seems harder to overcome, is how do I allocate memory for this thing ?: U
source share