This problem has been nagging me for a long while now. This will also be somewhat hard to explain, but was probably done before many times (my guess).
This is using rom/rot's codebase, so the structures for pointers and so on apply the same way.
The above is pseudocode obviously. The goal is to add a new object to a linklist thats within a linklist. The next part of this is doing all this through another variable (as shown with 'temp'). The above code doesn't work because temp is just a copy. I've never actually learned c language through books or schooling so i maybe missing something thats easy for the rest.
Help would be appreciated.
This is using rom/rot's codebase, so the structures for pointers and so on apply the same way.
/* something along these lines */
typedef the_data THE_DATA;
struct the_data {
// variables
};
struct char_data {
THE_DATA *linklist;
};
THE_DATA *temp;
temp = ch->linklist
while ( temp != NULL )
temp = temp->next;
temp = memoryallocation;
temp->value = 20;
/* this would put the value 20 into the last object in the 'linklist' found in 'ch'. */
The above is pseudocode obviously. The goal is to add a new object to a linklist thats within a linklist. The next part of this is doing all this through another variable (as shown with 'temp'). The above code doesn't work because temp is just a copy. I've never actually learned c language through books or schooling so i maybe missing something thats easy for the rest.
Help would be appreciated.