Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define ZVETSENI 1.99
- void realokuj(int *arr, int* aktualni_delka, double nasobek)
- {
- int i;
- int nova_delka = (int)(nasobek * (*aktualni_delka));
- arr = (int *)realloc(arr,nova_delka*sizeof(int));
- if(arr==NULL)
- printf("Chyba alokace!!!\n");
- for(i=(*aktualni_delka);i<nova_delka;i++)
- arr[i]=i;
- *aktualni_delka = nova_delka;
- }
- int main(void)
- {
- int i, delka=9;
- int *pole = (int*)malloc(delka*sizeof(int));
- for(i=0;i<delka;i++)
- pole[i]=i;
- realokuj(pole,&delka,ZVETSENI);
- printf("Delka po 1. alokaci: %d\n", delka);
- realokuj(pole,&delka,ZVETSENI);
- printf("Delka po 2. alokaci: %d\n", delka);
- for(i=0;i<delka;i++)
- printf("%d\n",pole[i]);
- printf("## Delka pole: %d",delka);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement