Recently I started learning C ++ and met this problem:
File input.txt
5 7 1 6 4 3 4 4 3 4 5 6 7 8
Do not tell me how to write 5 elements from the 3rd line of the input.txt
file and 7 from the 4th line into 2 arrays.
For the case of a single line in the file:
in.open(f); char z; int i = 0; while(!in.eof()) { in >> z; a[i++] = z - '0'; } in.close(f);
The case of a few lines remains to you as an exercise.
Source: https://ru.stackoverflow.com/questions/46303/
All Articles