#define ALLOW_INSTRUCTOR_CODE /*************************************************************************** *************************************************************************** ****** BEFORE BEGINNING OR TURNING IN THIS EXERCISE IT IS EXTREMELY ****** ****** IMPORTANT THAT YOU READ, FULLY UNDERSTAND, AND ADHERE TO THE ****** ****** REQUIREMENTS STATED IN THE DOCUMENT TITLED, "ASSIGNMENT ****** ****** SUBMISSION REQUIREMENTS", DOWNLOADABLE FROM THE COURSE WEB ****** ****** SITE. ****** *************************************************************************** **************************************************************************/ /*************************************************************************** ************* C/C++ Programming 2: Assignment 6 - Exercise 1 ************* ********* BEGIN EXERCISE REQUIREMENT - THIS MUST BE A "C" PROGRAM ********* *************************************************************************** (1 point) Write functions GetPrintfPointer and GetPutsPointer: GetPrintfPointer syntax: int (*GetPrintfPointer(void))(const char *f, ...); Parameters: none Synopsis: Declares a pointer named pPrintf of appropriate type to point to the standard library printf function and initializes it to point to that function. Return: the initialized pointer named pPrintf, which points to the standard library printf function GetPutsPointer syntax: int (*GetPutsPointer(void))(const char *f); Parameters: none Synopsis: Declares a pointer named pPuts of appropriate type to point to the standard library puts function and initializes it to point to that function. Return: the initialized pointer named pPuts, which points to the standard library puts function Hint: Find and examine the prototypes for the standard C library printf and puts functions. * Never explicitly write a prototype for a library function. Instead, include the appropriate header file, which already contains the needed prototype. *************************************************************************** ************************ END EXERCISE REQUIREMENT ************************* **************************************************************************/ /*************************************************************************** * BEFORE PRINTING THIS ASSIGNMENT TO TURN IN, DELETE THIS COMMENT AND * EVERYTHING ABOVE IT. **************************************************************************/ /* * TODO: * REPLACE THIS COMMENT WITH YOUR TITLE BLOCK. */ /* * TODO: * REPLACE THIS COMMENT WITH YOUR C CODE, PLUS ANYTHING NECESSARY TO * SUPPORT MY TEST CODE BELOW. DO NOT INCLUDE ANY UNNEEDED HEADER FILES! */ /*************************************************************************** * BEFORE PRINTING THIS ASSIGNMENT TO TURN IN, DELETE THIS COMMENT AND * EVERYTHING BELOW IT. **************************************************************************/ /* ***** Change nothing below this comment without instructor permission. **** * Everything that follows was written to help test/verify your code. You * do not need to understand the details of my code to write yours! */ #ifdef ALLOW_INSTRUCTOR_CODE int main(void) { int rtnPrintf = GetPrintfPointer()("Testing %s %x %d %o\n", "\"printf\"", 25, 25, 25); int rtnPuts = GetPutsPointer()("Testing \"puts\""); printf("printf returned %d; puts returned %d\n", rtnPrintf, rtnPuts); return EXIT_SUCCESS; } #endif