C Language Q & A #7 (cont.)
The following program uses the coreleft statement (in Borland C) to get the “core” main memory for use by a program. To print an integer in hexadecimal notation, use the “%x” conversion specifier in the printf statement:
/* program to determine amount of free memory in computer */
#include <stdio.h>
#include <alloc.h> /* helper file for coreleft function */
main()
{
int i;
i = coreleft();
printf(“there are %x bytes of memory available.\n”, i);
}