C programming question

August 12, 2010 at 06:50:11
Specs: Windows XP, 521 ram
Good day sir. May I know how to insert string into tree in C programming(not C++)? As I know, I just can insert integer .Please help me, if can, email to <removed>. Thanks.

edited by moderator: Removed email address -Razor2.3

See More: C programming question

Report •

August 15, 2010 at 07:45:01
The tree's node structure has to be such that it will hold a string rather than an integer. As C has very primitive string handling, you have to either

1) allocate enough space in each node for the maximum sized string you'll allow (this can waste much space), or

2) allocate a string (character) pointer in each node, and malloc() each string out of the heap space as you use it (if you're constantly freeing and reallocating strings due to changes, this can cause problems with eating up your address space through heap fragmentation).

Report •
Related Solutions

Ask Question