Read set of coordiantes

Hi,

I have an input file like this

------------
A 1 B 2 C 3

A 2 B 3 C 4

-------------

I want to read the input file into a 2*3 array and eliminate the A,B,C just like this

[1][2][3]
[2][3][4]


How can I do this?

Thanks
Assuming that each element in the input file separated by whitespaces, you can just do this:
1
2
3
4
5
std::ifstream input("input.txt");
char c;
int arr[3];
// stops reading each element after a whitespace
input >> c >> arr[0] >> c >> arr[1] >> c >> arr[2];


- Exactly the same as you would with std::cin.
1
2
3
4
std::cout << "Enter an expression:\n";
char op;
int x, y;
std::cin >> x >> op >> y;
Last edited on
Thanks!
Topic archived. No new replies allowed.