Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Struktura **losowanie(int N) // N - ile struktur utworzyć
- {
- //////////////////// Alokacja pamięci na wskaźniki do struktur ////////////////////
- Struktura **tab_s = (Struktura**) malloc(N * sizeof(Struktura*));
- //////////////////// Liczby losowe ////////////////////////////////////////////////
- int zarodek;
- time_t czas;
- zarodek = time(&czas);
- srand(zarodek);
- //////////////////// Wypełnianie struktur /////////////////////////////////////////
- for (int i = 0; i < N; i++)
- {
- int losowy_int = (int) ((rand() % 10000) - 1000);
- char losowy_char = (char) (rand() % 22) + 66;
- float losowy_float = (float) (1000 + (i + 1));
- Struktura s = { losowy_int, losowy_char, losowy_float};
- tab_s[i] = (Struktura*) malloc(sizeof(Struktura));
- tab_s[i] = &s;
- printf("%d. 1.%d 2.%c 3.%f \n", i, tab_s[i]->i, tab_s[i]->c, tab_s[i]->f);
- }
- return tab_s;
- }
Advertisement
Add Comment
Please, Sign In to add comment