Reading a file

I have a file that looks like this
1,0,0 | 2,0,1 | 3,1,0 | 4,2,0

I need to read in three variables
x = 1
y = 0
z = 0
and using the | to divide the numbers.
I don't need the commas or |.
I am struggling on reading this file and inputting them into variables.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <fstream>

int main()
{
    const char comma = ',' ;
    const char bar = '|' ;

    std::ifstream file( "watever" ) ;
    int x, y, z ;
    char expect_comma, expect_bar ;

    while( file >> x >> expect_comma && expect_comma == comma &&
           file >> y >> expect_comma && expect_comma == comma &&
           file >> z >> expect_bar && expect_bar == bar )
    {
        // do something with x, y, z
    }
}
Topic archived. No new replies allowed.