Hello friends ! , in my following code in C I want to invert my linked list in the display using a πΏπ²π°ππΏππΆππ² π³uπ»π°ππΆπΌπ» ; but the code does not work !! Is there an error; thank you for mentioning it
#include<stdio.h>
#include<stdlib.h>
struct cellule{
int a;
struct cellule *suivant;
};
//Recursive function to display the list in invers order
void affichage (struct cellule *liste){
while (liste!=NULL){
affichage(liste->suivant);
printf(" %d β,liste->a);
}
}
int main()
{
struct cellule *liste,*p,*q,*r;
int n,i;
printf(βDonner le nombre dβelements de la liste:\nβ);
scanf(β%d",&n);
printf(βEntrer les elements de la liste:\nβ);
for(i=0;i<n;i++)
{
p=(struct cellule *)malloc(sizeof(struct cellule));
scanf(β%dβ,&(*p).a);
if(i==0) liste = p;
else (*q).suivant=p;
q=p;
}
affichage(liste);
printf(β\nβ);
system(βpauseβ);
return 0;
}