This repository has been archived on 2023-10-26. You can view files and clone it, but cannot push or open issues or pull requests.
VSMechatronics/C16/alloc_example_3.c

22 lines
486 B
C
Raw Normal View History

2022-04-08 15:12:38 +00:00
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
// Declare an integer array and an integer pointer
int *pData;
// Using calloc (same approach malloc)
pData = calloc ( 10000 , sizeof (int));
if ( pData == NULL)
{
printf ("\nMemory could not be allocated - terminating");
return -1; // Use minus one as we did not exit successfully
}
// We have our memory, make use of it here!
return 0; // Exit successfully
}