/* menu.c */ #include #include #include /*---------------------------------------------------------- showMenu() ----------------------------------------------------------*/ char showMenu( char *item,char *items ) { char *choice = (char *)malloc( 3*sizeof( char )); printf( "\n" ); printf( "A(dd) %s\n",item ); printf( "E(dit) %s\n",item ); printf( "D(elete) %s\n",item ); printf( "L(ist) %s\n",items ); printf( "Q(uit)\n" ); printf( "enter choice --> " ); choice = fgets( choice,3,stdin ); fflush( stdin ); return( tolower( choice[0] )); } /* end of menu() */ /*---------------------------------------------------------- strip() this function strips non-printable characters from the front and back of the argument string. it returns a pointer to the stripped string, terminated by '\0'. ----------------------------------------------------------*/ char *strip( char *s ) { char *p = s; while ( s[0] <= 32 ) { s++; } p = s; while ( p[0] >= 32 ) { p++; } *p = '\0'; return s; } /* end of strip() */