We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
CX51 not support strtoul library routine ! unsigned long x; unsigned char c[]="12345678" x = strtoul (c,NULL,10); returned zero ?
unsigned char c[]="12345678" I assume you do really have a semicolon at the end of the above line? Did you include stdlib.h? Stefan
I use strtoul() extensively in a command-line interface. Seems to work fine, though I usually use 0 as the third argument to allow for any base to be input. strtoul() will return zero if it doesn't like its input, say if the first character isn't a decimal digit. What is the value in the array c when the call occurs? The array is initialized data; did you include the code to copy initialized data from ROM to RAM in your project? What happens if you make a literal call (strtoul ("1234", NULL, 10))? You might consider declaring string constants as code. They can remain in your ROM that way and save some space. Your memory implementation may favor one location over the other.
If you select device P89C669 or other MX , this code not working (return FF..), If select no MX device working correctly !! #include <REG51M.H> #include <string.h> #include <stdlib.h> void main (void) { unsigned long v; unsigned char x[]="12345678"; while (1) { v=strtoul("1234",NULL,10); } }