Lab9

Home Up

 

 Lab1 ] Lab2 ] Lab3 ] lab4 ] lab5 ] lab6 ] Lab7 ] Lab8 ] [ Lab9 ] Lab10 ]

CP107  LAB 9

 

Lab  9 Objectives:

Use the array and pointer data structure as an argument to a function
Use an array that contains character and pointers
Use an array to contain a character string (terminated with a null character)
Able to use arrays of characters and strings
Able to use arrays of pointers to function
Able to create a simple menu driven program
Use functions
IO manipulators
Use relational operators and compound conditions such as and, or , not
Understand and use the following string library functions

 

LAB 9 PROCEDURE


Read the problem description carefully and create pseudo code from the information that is provided below. Using the pseudo that you just created, develop a computer program. Test the program and submit it. DO NOT SUBMIT PSEUDO CODE.  At the end of chapter 5 PowerPoint notes, there is plenty of help to do this problem. Do simply copy that program, homework assignment is slightly different.

LAB 9 ASSIGNMENTS


Write a menu driven program that displays menu choices to the user. User should have 5 menu choices.
Each menu choice will call a function from an ARRAY OF FUNCTIONS. Each function will demonstrate a string function. All functions take two char * and return void.

void MenuItem0( char *, char * );

………

void MenuItem3( char *, char * );

Example of a Menu to display to the user

    Enter a choice:

    0     Demonstrates use of string function strcpy
    1     Demonstrates use of string function strcat
    2     Demonstrates use of string function strcmp
    3     Demonstrates use of string function strtok
           ....................
           ....................
    4     End program


Example of declaring an array of pointers to a function
void (*MenuItem_Array[MAX_MENU_ITEMS])(char *, char *) =  {
                    MenuItem0,     // Demonstrates use of string function strcpy
                    MenuItem1,     // Demonstrates use of string function strcat
                    MenuItem2,     // Demonstrates use of string function strcmp
                    MenuItem3     // Demonstrates use of string function strtok
                    };

 

Copyright (c) Yusuf Family Website 2001