manquant ‘;’ avant ‘type’

#include  #include  typedef struct student { int rollNo; char studentName[25]; struct student *next; }node; node *createList(); void printList(node *); int main() { node *head; head = createList(); void printList(node *head); return 0; } node *createList() { int idx,n; node *p,*head; printf("How many nodes do you want initially?\n"); scanf("%d",&n); for(idx=0;idxnext = (node*)malloc(sizeof(node)); p = p->next; } printf("Enter the data to be stuffed inside the list \n"); scanf("%d %s",&p->rollNo,p->studentName); } p->next = NULL; p = head; /*while(p) { printf("%d %s-->\n",p->rollNo,p->studentName); p=p->next; }*/ return(head); } void printList(node *head) { node *p; p = head; while(p) { printf("%d %s-->\n",p->rollNo,p->studentName); p=p->next; } } 

Qu’est-ce qui pourrait être faux ici? Je sais que j’ai fait quelque chose de stupide, je ne peux pas comprendre ce que c’est. Je reçois ces erreurs

  error C2143: syntax error : missing ';' before 'type' error C2143: syntax error : missing '{' before '*' error C2371: 'createList' : redefinition; different basic types 

 int main() { node *head; head = createList(); void printList(node *head); // This isn't how you call a function return 0; } 

Changer en:

 int main() { node *head; head = createList(); printList(head); // This is. return 0; } 

Cette ligne dans main() est votre problème:

 void printList(node *head); 

CA devrait etre:

 printList(head); 

Vous voulez appeler la fonction ici, sans essayer de la déclarer.