char buf[MAX_STRING_LENGTH];
memcpy(buf, array, sizeof(array));
buf[sizeof(array)] = '\0';
const char *const *arr
struct dynamic_array
{ void ** array;
int len;
};
str += "Another line of output\r\n";
if(str = realloc(str, strlen(str) + strlen("Another line of output\r\n") + 1))
strcat(str, "Another line of output\r\n");
else
abort("Cannot allocate memory!");
template <typename T, size_t N>
size_t length_of_statically_allocated_array(T (&arr)[N])
{
return N;
}
int main()
{
char foo[769];
printf("%d\n", length_of_statically_allocated_array(foo));
}
So, I've written a piece of code to make it easier to spit out data in an array to a character so I don't have to use forloops everytime in the middle of my code.
It looks like this:
What's happened is its only ever reading array as one entry large. So, it will spit out the first one then quit. I did a bug message to test sizeof( array ) / sizeof( array[0] ) and sure enough it was 1.
I think I know why this is happening, but anyone know of a way to make this work?
Thanks, Davenge