Untitled
unknown
plain_text
4 years ago
1.1 kB
7
Indexable
int count(struct node *start); int printlist(struct node *start); int createlinklist(struct node *start); struct node { int item; struct node *next; }; #include<stdio.h> #include<conio.h> #include<stdlib.h> void main() { struct node *start; clrscr(); start=(struct node *)malloc( sizeof(struct node)); createlinklist(start); printlist(start); count(start); getch(); } int createlinklist(struct node *start) { int item; printf("at the end node you can enter -20\n"); printf("enter your item"); scanf("%d",&item); if(start==NULL) printf("no linked list can be create\n"); else { start->item=item; if(start->item==-20) { start->next=NULL; exit(0); }; start->next=(struct node *)malloc(sizeof(struct node)); createlinklist(start->next); } return(0); } int printlist(struct node *start) { printf("%d\n",start->item); if(start==NULL) printf("all the element has been printed"); printlist(start->next); return(0); } int count (struct node *start) { if(start==NULL) return(0); else return(1+count(start->next));
Editor is loading...