Hi all!
In a program for my diploma project I want use the strtol function which extract a long from a string. Regarding to CCS Compiler reference manual the following code should give result = 123 and ptr = "hello"
Code:
signed long result;
char str[2]="123hello";
char *ptr;
result=strtol(str,&ptr,10);
Two questions about this example:
1. str is declared to be 2 of length should it not be 9 for avoiding overwrite?
2. This example works well if str is stored in lower adresses (<255). If str is stored for example at adress 0x100 ptr should be 0x0103 but is 0x0003 in reality as if only lower byte was copied... Is this a problem of 8 bit or 16 bit pointers? Should a char **ptr (double indirection) be used as in standard C strtol?
I'm using a PIC18F452 with #device *=16 directive and CCS 3.239.
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Wed Nov 23, 2005 3:22 pm
I made a test program based on your post and I did see a problem.
Maybe you should report this to CCS.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum