I have input such as \"(50.1003781N, 14.3925125E)\"
.These are latitude and longitude.
I want to parse this with
sscanf(string,\"(%lf%c
Process the string first using
char *p;
while((p = strchr(string, 'E')) != NULL) *p = 'W';
while((p = strchr(string, 'e')) != NULL) *p = 'W';
// scan it using your approach
sscanf(string,"(%lf%c, %lf%c)",&a,&b,&c,&d);
// get back the original characters (converted to uppercase).
if (b == 'W') b = 'E';
if (d == 'W') d = 'E';
strchr()
is declared in the C header
.
Note: This is really a C approach, not a C++ approach. But, by using sscanf()
you are really using a C approach.