Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- void print_mas(int * ptr, int N)
- {
- for(int i = 0; i < N; i++)
- printf("%d ",ptr[i]);
- printf("\n");
- }
- int main(int argc, char const *argv[])
- {
- int* arr; //
- int N; // int arr[N];
- scanf("%d", &N);
- arr = (int*)calloc(N, sizeof(int));
- for(int i = 0; i < N; i++)
- arr[i] = i*2;
- print_mas(arr, N);
- N++;
- arr = (int*)realloc(arr,N * sizeof(int));
- arr[N-1] = 10;
- print_mas(arr, N);
- N = 1;
- arr = (int*)realloc(arr, N * sizeof(int));
- print_mas(arr, N);
- free(arr);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement