You can pass a buffer reference or use a global variable.
When you use the link as in
void func(TypeName *dataStructure, LL_Node **accumulator, char buffer[]) { func(datastructure->left, accumulator, buffer); func(datastructure->right, accumulator, buffer); { char buffer[1000];
you are passing a link, just a pointer to the beginning of the array, so you need to remember its length.
If you decide to use a global variable, you do not actually use the stack, but allocate program memory, a common space where code and data coexist (code is data). Therefore, you never use one byte of an extra bar in your calls if you do it this way:
char buffer[1000]; void func(TypeName *dataStructure, LL_Node **accumulator) { func(datastructure->left, accumulator); func(datastructure->right, accumulator); {
It is up to you to choose one. The second is for each recursive call, but increases the size of the program. The first one is more elegant for some, but a little slower, perhaps not even noticeable.
Manuel ferreria
source share