/* */
/* This program determines the maximum contiguous */
/* memory allocation that can be reserved during a */
/* specific program execution. */
#include <stdio.h>
#include <stdlib.h>
#define UNIT 1000000
int main(void)
{
/* Declare and initialize variables. */
double k=1;
int *ptr;
/* Find maximum amount of contiguous memory */
/* available in units of millions of integers. */
ptr = (int *)malloc(UNIT*sizeof(int));
while (ptr != NULL)
{
printf("%f integers \n",(k)*UNIT);
free(ptr);
k++;
ptr = (int *)malloc(k*UNIT*sizeof(int));
}
/* Print maximum amount of memory available. */
printf("Maximum contiguous memory available: \n");
/* Exit program. */
return 0;
}
HOMEWORK:
/* */
/* This program reads a seismic data file and then */
/* determines the times of possible seismic events. */
/* Dynamic memory allocation is used. */
#include <stdio.h>
No comments:
Post a Comment