| Block{ id value origin.x origin.y ending.x ending.y name } Block{ 7 7 0 0 3 2 aaaaa } Block{ 7 7 0 3 3 5 aaaaa } Block{ 7 7 4 0 6 2 aaaaa } Block{ 7 7 4 3 6 5 aaaaa } Block{ 7 7 7 0 9 2 aaaaa } Block{ 7 7 7 3 9 5 aaaaa } Block{ 7 7 10 0 12 2 aaaaa } Block{ 7 7 10 3 12 5 aaaaa } Block{ 7 7 0 7 3 10 aaaaa } |
|
|
while (getline(file, line))"Block{ 7 7 0 0 3 2 aaaaa }"file >> b.m_id, ¿where are you reading? you are on the next line, "Block"while (getline(file, line, '{')), `line' would have "Block" (the space is discarded) and then file >> b.m_id will read the number |
|
id: 7
value: 7
origin: {0; 0}
ending: {3; 2}
name: aaaaa
- - -
id: 7
value: 7
origin: {0; 3}
ending: {3; 5}
name: aaaaa
- - -
id: 7
value: 7
origin: {4; 0}
ending: {6; 2}
name: aaaaa
- - -
id: 7
value: 7
origin: {4; 3}
ending: {6; 5}
name: aaaaa
- - -
id: 7
value: 7
origin: {7; 0}
ending: {9; 2}
name: aaaaa
- - -
id: 7
value: 7
origin: {7; 3}
ending: {9; 5}
name: aaaaa
- - -
id: 7
value: 7
origin: {10; 0}
ending: {12; 2}
name: aaaaa
- - -
id: 7
value: 7
origin: {10; 3}
ending: {12; 5}
name: aaaaa
- - -
id: 7
value: 7
origin: {0; 7}
ending: {3; 10}
name: aaaaa
- - - |
|
|
ne555 suggested, but it works: |
|
|
|
file >> std::cin::ignore() >> b.m_id >> b.m_value >> b.m_origin.x >> b.m_origin.y >> b.m_ending.x >> b.m_ending.y >> b.m_name;