Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct Test
- {
- int a;
- };
- void inicjalizacja(struct Test*tab, int rozmiar)
- {
- for (int i = 0; i < rozmiar; i++)
- {
- tab[i].a = 10;
- }
- }
- void odczyt(struct Test *tab, int rozmiar)
- {
- for (int i = 0; i < rozmiar; i++)
- {
- printf("element : %d \n", tab[i].a);
- }
- }
- void pamiec(struct Test** data, int size)
- {
- *data = (struct Test*)malloc(sizeof(*data) * size);
- }
- void usuwaniepamieci(struct Test *tab)
- {
- free(tab);
- }
- int main(void)
- {
- struct Test* tab;
- const int size = 5;
- pamiec(&tab, size);
- inicjalizacja(tab, size);
- odczyt(tab, size);
- usuwaniepamieci(tab);
- //wypisuje 2 element
- printf("element : %d \n", tab[2].a);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement