Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define MAX 50
- typedef struct nodo{
- char cognome[MAX];
- char nome[MAX];
- int eta;
- int prezzo;
- struct nodo* link;
- };
- void add(struct nodo * head, int n){
- struct nodo* nuovo =(struct nodo*)malloc(sizeof(struct nodo));
- nuovo->eta=n;
- nuovo->link=NULL;
- if(head->link==NULL){
- head->link=nuovo;
- }else{
- add(head->link,n);
- }
- }
- void display(struct nodo * head){
- if(head){
- printf("%d\n",head->eta);
- display(head->link);
- }
- }
- int main(int argc, const char * argv[]) {
- struct nodo* head =(struct nodo*)malloc(sizeof(struct nodo));
- head->eta=2;
- add(head,4);
- add(head,4);
- add(head,4);
- add(head,4);
- add(head,4);
- display(head);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment