Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- typedef struct lista
- {
- char napis[20];
- struct lista *n;
- } element;
- void wpisz(element **pocz);
- void czyt_l(element *pocz);
- int main()
- {
- element *slowa;
- //slowa=malloc(sizeof(element));
- wpisz (&slowa);
- czyt_l(slowa);
- return 0;
- }
- void wpisz(element **slowo)
- {
- int d;
- char c, w[20];
- element *pom=*slowo;
- printf("\ndaj cos oprocz 0!");
- scanf("%d", &d);
- while(d)
- {
- printf("\nPodaj napis: ");
- scanf("%s", pom->napis);
- printf("\ndaj cos oprocz 0!");
- scanf("%d", &d);
- if(d==0)
- {
- pom->n=NULL;
- return;
- }
- pom->n=malloc(sizeof(element));
- pom=pom->n;
- }
- *slowo=NULL;
- }
- void czyt_l(element *slowo)
- {
- int i;
- element *c;
- c=slowo;
- printf("\n");
- if(c==NULL) printf("\nLista pusta!");
- for(i=0; c!=NULL; i++,c=c->n) printf("%d slowo w liscie: %s\n",i+1, c->napis);
- }
Advertisement
Add Comment
Please, Sign In to add comment