Advertisement
WizardRubic

malloc array

Jun 28th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main() {
  5.     int x;
  6.     printf("Enter int: ");
  7.     scanf("%d",&x);
  8.     printf("Allocating an int array of length: %d\n",x);
  9.     int * pX = malloc(x*sizeof(int));
  10.     printf("Freeing the int array. Some languages do this automatically!\n");
  11.     free(pX);
  12.     return 0;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement