Struct:
Code:
typedef struct tnode {
int id;
char *artist;
char *title;
char *remixer;
char *label;
int year;
char *genre;
char *project;
int mark;
char *class;
int class_number;
struct tnode *next;
struct tnode *prev;
} Treenode;
I made a head pointer in main, and I set the current pointer to the head:
Code:
/* Set tree_current_ptr to the tree head. */
tree_current_ptr = tree_head_ptr;
I call this function with the tree_current_ptr so that its position can get modified in the function:
Code:
void print_rows(Treenode **start, Windownode *node, float *spaces, int num_rows, int direction)
{
int count_rows;
int pos_y, pos_x=0;
int limit;
Treenode *cur = *start;
#ifdef _DEBUG_
curs_set(1);
#endif
if(direction == PRINT_FWD) {
pos_y = 0;
limit = node->sub_window->display->max_y;
for(count_rows=0; cur && (count_rows < num_rows) && (pos_y < limit); ++count_rows, ++pos_y, cur=cur->next) {
print_row(node->sub_window, cur, spaces, pos_y, pos_x);
wrefresh(node->sub_window->win);
}
} else if (direction == PRINT_BKWD) {
pos_y = node->sub_window->display->max_y - 1;
limit = 0;
for(count_rows=0; cur && (count_rows < num_rows) && (pos_y >= limit); ++count_rows, --pos_y, cur=cur->prev) {
print_row(node->sub_window, cur, spaces, pos_y, pos_x);
wrefresh(node->sub_window->win);
}
}
#ifdef _DEBUG_
curs_set(0);
#endif
}
In main I do:
Code:
print_rows(&tree_current_ptr, win_parent[MAIN], spaces, 40, PRINT_FWD);
However, in the for loop, when I set cur = cur->next, the tree_current_ptr comes out unaltered. My code like this compiles. I tried setting it like (*cur)=cur->next, but that didn't compile. I also tried just passing a pointer to the struct as a parameter, but that didn't work. What am I missing about modifying the struct member?