Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int rozmiar=NULL;
- void push(int *dane,int liczba)
- {
- rozmiar=rozmiar+1;
- realloc(dane,rozmiar*sizeof(int));
- dane[rozmiar-1]=liczba;
- }
- void wyswietl(int *liczba)
- {
- int *wsk=&liczba[0];
- int i;
- for(i=0;i<rozmiar;i++)
- {
- printf("%d \n",*(wsk++));
- }
- }
- int main()
- {
- int *dane;
- dane = malloc(rozmiar*sizeof(int));
- push(dane,5);
- printf("Liczby w stosie: \n");
- wyswietl(dane);
- push(dane,6);
- printf("Liczby w stosie: \n");
- wyswietl(dane);
- push(dane,7);
- printf("Liczby w stosie: \n");
- wyswietl(dane);
- push(dane,8);
- printf("Liczby w stosie: \n");
- wyswietl(dane);
- push(dane,9);
- printf("Liczby w stosie: \n");
- wyswietl(dane);
- push(dane,10);
- printf("Liczby w stosie: \n");
- wyswietl(dane);
- free(dane);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement