02-14-2019 07:22 AM - edited 02-14-2019 07:24 AM
The code sscanf("-0", "%d", &x) returns -2147483648 (hex 80000000) if x is an integer or long.
This is causing a problem in my radar test tool when I try to parse a string containing latitude/longitude coordinates in order to separate it into degrees and minutes. For example, sscanf("-0:12.34", "%d:%f", °, &min) will return -2147483648 for the degrees.
I'm using LabWindows 2013/2015 on Windows 7/10.
02-14-2019 08:08 AM - edited 02-14-2019 08:37 AM
I have to note that Scan is more tolerant on the input string: Scan ("-0:12", %d[x]%d[x]" °, &min); returns deg = 0, min = 12.
But if you want to conform to standard libraries then you could try with sscanf (msg, "%c%d:%d", sign, °, &min); and post-process the results elaborating on 'sign' value. Nevertheless, this approach will fail if no sign character is present at the beginning of the string; that is, if your string may or may not begin with a sign you will need to pre-process the string testing for a digit in the first position.