C   90

malloc

Guest on 14th July 2022 02:12:33 AM

  1. // see Bb --> headerfiles links to see what these libraries mean.
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <limits.h>
  5. #include <float.h>
  6. #define n 10
  7.  
  8. int main(int argc, char* argv[]){
  9.         int* A = NULL;
  10.         int i;
  11.         if ((A = malloc(sizeof(int)*n)) != NULL)
  12.         {
  13.                 for (i=0;i<n;i++)
  14.                   *(A+i) = 0;
  15.         }
  16.         else
  17.         {       printf("malloc failed: Exiting Program!\n\n");
  18.                 exit( EXIT_FAILURE );
  19.         }
  20.   return EXIT_SUCCESS;
  21. }

Raw Paste


Login or Register to edit or fork this paste. It's free.