INSTRUCTOR SUPPLIED DRIVER FILE:
#define INSTRUCTOR_FILE #ifdef INSTRUCTOR_FILE
#include #include
int (*GetPrintfPointer(void))(const char *format, ...); int (*GetPutsPointer(void))(const char *str);
int main(void) { int rtnPrintf = GetPrintfPointer()("Testing %s %x %d %o ", "\"printf\"", 25, 25, 25);
int rtnPuts = GetPutsPointer()("Testing \"puts\"");
printf("printf returned %d; puts returned %d ", rtnPrintf, rtnPuts);
return EXIT_SUCCESS; } #endif
See attached for clearer picture
C2A6E1 (2 points - Program) Exclude any existing source code files that may already be in your IDE project and add a new one, naming it C2A6E1_GetPointers.c. Also add instructor-supplied source code file C2A6E1_main-Driver.c. Do not write a main function! main already exists in the instructor-supplied file and it will use the code you write. File C2A6E1_GetPointers.c must contain functions named GetPrintfpointer and Get PutsPointer. GetPrintfpointer syntax: int (*GetPrintfpointer(void))(const char *format, ...); 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. It does all of this in one single statement. Return: the initialized pointer named printf, which points to the standard library printf function GetPutsPointer syntax: int (*GetPutsPointer(void)) (const char *str); Parameters: none Synopsis: Declares a pointer named puts of appropriate type to point to the standard library puts function and initializes it to point to that function. It does all of this in one single statement. Return: the initialized pointer named pPuts, which points to the standard library puts function Never explicitly write a prototype for a library function. Instead, use #include to include the appropriate standard library header file. It will aiready contain the needed prototype. The GetPrintfpointer and GetputsPointer functions must each contain two and only two statements: 1. The statement that declares and initializes the pointer. 2. The statement that returns the pointer. Submitting your solution Send both source code files to the assignment checker with the subject line C2A6E1_ID, where ID is your 9-character UCSD student ID See the course document titled "How to Prepare and Submit Assignments" for additional exercise formatting submission, and assignment checker requirements. Hints: Look up the standardi library printf and puts functions in your IDE's built-in help, any good C programming text book, or online, and examine their prototypes. none C2A6E1 (2 points - Program) Exclude any existing source code files that may already be in your IDE project and add a new one. naming it C2A6E1 GetPointers.c. Also add instructor-supplied source code file C2A6E1_main-Driver.c. Do not write a main function main already exists in the instructor-supplied file and it will use the code you write. File C2A6E1_GetPointers.c must contain functions named GetPrintfpointer and Get PutsPointer. GetPrintfPointer syntax int ("GetPrintfPointer(void))(const char *format, ...); Parameters: 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. It does all of this in one single statement. Return: the initialized pointer named pPrintf, which points to the standard library printf function GetPutsPointer syntax int ("GetPutsPointer(void)) (const char *str); 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. It does all of this in one single statement. Return: the initialized pointer named pPuts, which points to the standard library puts function Never explicitly write a prototype for a library function. Instead, use #include to include the appropriate standard library header file. It will already contain the needed prototype. The GetPrintfPointer and GetPutsPointer functions must each contain two and only two statements: 1. The statement that declares and initializes the pointer. 2. The statement that returns the pointer. Submitting your solution Send both source code files to the assignment checker with the subject line C2A6E1_ID. where ID is your 9-character UCSD student ID See the course document titled "How to Prepare and Submit Assignments for additional exercise formatting, submission, and assignment checker requirements. Hints: Look up the standard library printf and puts functions in your IDE's built-in help. any good C programming text book, or online, and examine their prototypes