This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software:
I have a graphics package that to display a listbox requires an array of pointers to C strings to display in each row. The array of strings I'm displaying is created dynamically so I have an array of fixed length strings that I populate and then dynamically populate an array with the addresses of each of those strings:
char* pListBuff[Size];
char ListBuff[Size][charsPerString];
Since the addresses of each string in ListBuff is known at compile time, is there a way in the compiler to create: const char* pListBuff[Size]; ??
Thanks,
Doug
Since the addresses of each string in ListBuff is known at compile time, is there a way in the compiler to create: const char* pListBuff[Size]; ??
Hi Doug,
I think you are asking a C language question rather than MCU. Not an expert in string manipulation but I think the below should work.
char *pListBuff[3] = { "Apple", "Orange", "tomato" };
pListBuff[0] = "Pear"; // Change from Apple to Pear. Need to make sure the length of the new string is not longer than the initialized string
Hi Charles
It is a CCS compiler question, but when I start a new inquiry it requires a part number and forces me into the ARM thread.
Yes, what I can do is:
char List[200][20]; // Array of 200, 20 character strings.
const char* pList[200] = {&List[0], &List[1], &List[2] ... &List[199] }; // Array of pointers to the 20 character strings.
But I was hoping there was some compiler extension that would allow me to do this algorithmically instead of having to type out the list of addresses.
Thanks
Doug
Hi Doug,
I'm not sure what compiler extension you are referring to but I will pass your post to our compiler expert for comments.