I have .txt
file with text like this inside (this is just a fragment):
...
[332, 605]-[332, 592], srednica: 13
[324, 593]-[332, 605], srednica: 14.4222
[323, 594]-[332, 605], srednica: 14.2127
[323, 594]-[331, 606], srednica: 14.4222
[324, 593]-[324, 607], srednica: 14
[323, 594]-[323, 607], srednica: 13
[319, 596]-[319, 607], srednica: 11
[320, 595]-[320, 607], srednica: 12
...
What i need to to is get a first 4 numbers from each line and store them into integers.
I have tried smth like this:
ifstream file("punkty_srednice.txt");
string line;
int ax, ay, bx, by;
while(getline(file, line)) {
stringstream s(line);
string tmp;
s >> tmp >> ax >> tmp >> ay >> tmp >> bx >> tmp >> by >> tmp;
cout << ax << " " << ay << " " << bx << " " << by << endl;
}
Output (just a part of it):
...
506 506 -858993460 -858993460
503 503 -858993460 -858993460
495 503 -858993460 -858993460
497 503 -858993460 -858993460
500 497 -858993460 -858993460
492 503 -858993460 -858993460
...
As u an see there are some strange numbers like -858993460
I did other try by deleting tmp
and going straight like this:
s >> ax >> ay >> bx >> by;
but then output contains only trash numbers like -858993460
How i can deal with it?