#include #include #define MAXVALS 4 int main(void){ // allocate space for a float on the heap, // return a pointer to it, // cast it to a float* , // store it in f; float* pf = (float*) malloc( sizeof(float) ); if(pf == (float*)NULL){ fprintf(stderr, "Memory allocation failed. Program terminating."); return EXIT_FAILURE; } printf("Please enter a float value: "); scanf("%f",pf); // pf is a pointer, with space allocated to it printf("%f it is!\n", *pf); free(pf); // all done with fp // allocate space for an integer [] that hold MAXVALS ints on the heap, // return a pointer to it, cast the void* to a int* , and store it in arr; int iErr; int* arr = (int*) malloc( sizeof(int)*MAXVALS ); if(arr == (int*)NULL){ fprintf(stderr, "Memory allocation failed. Program terminating."); return EXIT_FAILURE; } printf("Please enter %d integer values: ", MAXVALS); for(int i=0; i