Tool/software: TI C/C++ Compiler
According to C++ specification, the value returned by sscanf should match the number of items successfully filled. (link)
I tried the following (compiler TI v5.2.5):
bool ToFloat(char* string, float* data)
{
int temp = sscanf(string, "%f", data);
return (1 == temp);
}
int main(void)
{
char testdata[] = "EPRP";
float parsed;
bool res = ToFloat(&testdata[0], &parsed);
...
The sscanf returns in this case 1, and the data is 0.0. I tried other strings, like "XXXX" or "PERP", these return 0 as expected.
I tested it with different compilers:
All of them return 0 as expected, so I guess the TI v5.2.5 compiler (also TI v18.1.1.LTS) has an issue with strings starting with 'E' (probably because of the engineering notation?).
Is there a workaround for this problem, or is there a version of stdio library available which works correctly?
Thank you