The error is, essentially, what your compiler says it is. You are passing, as first argument, data[i].left
, which is of type short int, whereas a pointer to struct afreq
is needed. The only reason why it compiles anyway is because gcc, by default, allows conversions between int and pointer (but there's not many reasons why you would want to do that).
If I understand correctly what you are trying to do - you want to call recursively your "dictionary" function on what seems to be a tree. The problem is that that structure is not really well defined. You are trying to "index" the nodes of the tree with their value (that's what I understand with the data[i].left
), but there is no way to "make the link" between, say, 'a'
, and "the struct afreq
that has 'a'
as a symbol. You either need to make a correspondance table somewhere and make a call to it, or you need to transform left
and right
in your structure into pointers to the corresponding structure.
Good luck!