buffer is a protected void* part of my class.
void* ptr;
ptr= buffer;
if(ptr == pvTxt)
return ptr;
while (*((unsigned char*)ptr) || *(((unsigned char*)ptr)+1))
((unsigned char*)ptr)++;
return *((unsigned char*)ptr)+1;
Everything up to the:
((unsigned char*)ptr)++;
return *((unsigned char*)ptr)+1;
is fine but I know there is something wrong with the casting?
Also in my main I have:
g_pvTxt = new unsigned char[BUFSIZE];
memset (g_pvTxt,0,BUFSIZE);
Given the question above how do I append an array. Create an array/append to it. Can’t use std::vector because it’s an embedded system
To further explain the loop:
After an txt entry there is a null termination. At the end of all entries there is a double null. So, in the while loop if the value the pointer is pointing at is false (either 0 or 00) or ptr || ptr+1, it will increment the counter until it gets to the next spot where I can append values.
Why don’t you just make the cast to
unsigned char*only once?If you want to append to a buffer, and cannot use
std::vectoryou can do something similar: allocate a bigger buffer, copy everything over and delete the old buffer.