Character pointer problem
Hi all,
I'll warn you all now this is my first attempt at programming in C so this is probably a very basic question. Basically I have an n-ary tree which contains a char pointer called value. I assign this a temporary value of say 'xyz'. I then parse this value to read each character and assign that character to a new node. The code to loop though the value is as follows:
Code:
for (j = 0; j < strlen(t->value); j++) {
add_child_node(t, &(t->value[j]));
}
The problem is if value is 'xyz' the first time round i get 'xyz' then the 2nd i get 'yz' and then finally 'z'. I can see why this happens but obviously it is not what i want. I just want 'x' then 'y' then 'z'. Can anyone give me some help on how I would do this?
Thanks,
James