I currently have a problem converting strings to longs. I tried atol, strtol, strtoul. Only atoi seems to work.
sprintf longs using %lu does not seem to work, but ltoa does.
To test these functions, I use something like
sprintf(returnBuffer, "12345");
LCD_WriteString(returnBuffer, 5, 0, 1);
userID = atol(returnBuffer);
// userID = (long) 30010; // test if ltoa/sprintf works
ltoa(userID, returnBuffer, 10);
LCD_WriteString(returnBuffer, 6, 0, 1);
The LCD values are not the same. First display is correct, but second only shows "0".
If you compile with -Wall, do you see:
test.c:25:5: warning: implicit declaration of function ‘atol’ [-Wimplicit-function-declaration]
test.c:27:5: warning: implicit declaration of function ‘ltoa’ [-Wimplicit-function-declaration]
If so, you need to #include <stdlib.h>, otherwise the compiler assumes ltoa returns a (16-bit) int, and you will only see the high 16 bits of the return value, which are zero in this case.
-Wall was really useful. Now project is cleaned up.
Unsigned Long functions are now working.
Thanks.