Hvorfor får jeg fejl i mine pointer-for-løkke i linie 45 og 53? ------------------------------------------------------- #include <stdio.h> typedef struct node *nodeptr; //struct node kendes som nodeptr struct node{ //Struktur for node char *name; int grade; nodeptr *next; }; nodeptr nodealloc(grade){ struct node *tmp; tmp=(struct node *) malloc(sizeof(nodeptr)); if (tmp == NULL){ exit(1); } tmp->grade = grade; tmp->next = NULL; }
nodeptr *head; //holder først adresse i linkedlist
//head=&head //Omvendt udskrivning int count1;//Antal objekter i linkedlist int count2;//Position i linkedlist //int location; //Sortering /*nodeptr max_address; int max_position; nodeptr max_next; nodeptr tmp_head; */ main(){
}
void insert_node(struct node node){ node.next = head; //node peger på hvad head peger på head = *node.next; //head peger på node }
} */ void sort_list(nodeptr head){ int count1=numobjects(head);//antal obj. gemmes i count1. //VARS--- int max=0; nodeptr max_adress, max_next; int max_position; //------- int count2=0; for(count1>0;count1--){
Der kommer lige en update på source'n: ----------------------------------------------------------------- #include <stdio.h> typedef struct node *nodeptr; //struct node kendes som nodeptr struct node{ //Struktur for node char *name; int grade; nodeptr *next; }; nodeptr nodealloc(grade){ struct node *tmp; tmp=(struct node *) malloc(sizeof(nodeptr)); if (tmp == NULL){ exit(1); } tmp->grade = grade; tmp->next = NULL; }
nodeptr *head; //holder først adresse i linkedlist
//head=&head //Omvendt udskrivning int count1;//Antal objekter i linkedlist int count2;//Position i linkedlist //int location; //Sortering /*nodeptr max_address; int max_position; nodeptr max_next; nodeptr tmp_head; */ main(){
}
void insert_node(struct node node){ node.next = head; //node peger på hvad head peger på head = *node.next; //head peger på node }
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.