C ++ istringstream and whitespace

I have this input: (50.1003781N, 14.3925125E)which is stored in const string & input. What I'm trying to do is extract the brackets, get the number representing the GPS coordination - 50.1003781, save N and do the same for the second coordinate.

So here is my code:

istringstream iStream(input);

char brackets[2]; //To store the brackets 
char types[2]; //To store if it is N/S or W/E
char delim; //To store ","
double degrees[2];

iStream >> brackets[0] >> degrees[0] >> types[0] >> delim;

//The delim loads the "," and here goes my problem with whitespace which is next

iStream >> degrees[1] >> types[1] >> brackets[1];

But it does not work on loading degrees[1], it loads zero, and tellg()says -1, probably due to a space after the decimal point. The syntax line should be like this:

cout << brackets[0]; // "("
cout << degrees[0]; // "50.1003781"
cout << types[0]; // "N"
cout << delim; // ","
cout << degrees[1]; // "14.3925125"
cout << types[1]; // "E"
cout << brackets[1]; // ")"

I tried skipws and noskipws, but with no effect. Can anyone help please? Many thanks.

+4
source share
1 answer

, , E in 14.3925125E . E 10 , . , 5.23E4 5.23 * 10^4.

, E, , degrees[1].

degrees[1] , E .

+8

Source: https://habr.com/ru/post/1533627/


All Articles