How can I read integers from a file to the array of integers in c++? So that, for example, this file's content:
23
31
41
23
would become:
int *arr = {23, 31, 41, 23};
?
I actually have two problems with this. First is that I don't really know how can I read them line by line. For one integer it would be pretty easy, just file_handler >> number
syntax would do the thing. How can I do this line by line?
The second problem which seems more difficult to overcome for me is - how should I allocate the memory for this thing? :U