|
|
|
|
My question is why it's printing "Can't set child at 3, no parent found"
|
|
|
tree[(0 * 2) + 1]
. That is, to tree[1].
|
|
when I uncomment setleft(b,0) |
setleft( 'b', 0 );
modify?What can you tell about values of 'foo' and 'bar' on line XX? |
set_left()
and set_right()
to print the index of the parent instead of the child:
|
|
set_left(D,1): Can't set child because parent node doesn't exist. set_right(E,1): Can't set child because parent node doesn't exist. |
|
|
stonedviper wrote: |
---|
Because that's not how a binary tree is implemented it's implemented as follows struct node { int el; node*left; node*right; } |
|
|
If an initializer is not provided: * objects with automatic storage duration are initialized to indeterminate values (which may be trap representations) * objects with static and thread-local storage duration are initialized as follows: - pointers are initialized to null pointer values of their types - objects of integral types are initialized to unsigned zero - objects of floating types are initialized to positive zero - members of arrays, structs, and unions are initialized as described above, recursively, plus all padding bits are initialized to zero |
char tree[10];
is not inside any function. Therefore, it is at file scope.If no storage-class specifier is provided, the defaults are: - extern for all functions - extern for objects at file scope - auto for objects at block scope |
The extern specifier specifies static storage duration and external linkage. |
'\0'
, aka null.