Hi gents and ladies, ver 3.234, is there a way to define the length of an array to capture a_to_d readings after compilation of the program, in other words by entering a value from a keypad that tells the program the length of the array.
Cheers dave
MikeValencia
Joined: 04 Aug 2004 Posts: 238 Location: Chicago
Posted: Wed Nov 02, 2005 7:08 am
I never tried it in the PIC environment, but i'll try to explain it the way i understand it to work:
Arrays are defined during compile-time, so you can't really define the length on-the-fly.
I think the solution you'd be looking for is to define a pointer to a char:
char *my_ptr;
Then you do a malloc() for the length you want.
e.g.
my_ptr = malloc(...);
After that, then you can address the contents accordingly via:
my_ptr[x] = 0x20; // for example
or
*(my_ptr + x) = 0x20;
I think the two statements above are equal, but I am not sure if CCS supports both.
OR
The easiest would be to just define an array of your worst-case longest length.
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