Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can someone make a menu?

Status
Not open for further replies.

Miltecnico

Technical User
Apr 6, 2004
1
US
I was wondering if someone could show me how I can make a menu using C, basically I just was thinking like you have 5 options you can choose from. I'm not much of a programmer, but I have some visual studio software and any help is appreciated, thanks :)
 
Three basic elements

Print the menu
Code:
printf( "1. Open file\n" );

Get the user choice
Code:
char buff[100];
int choice;
fgets( buff, sizeof buff, stdin );
sscanf( buff, "%d", &choice );

Take the appropriate action
Code:
if ( choice == 1 ) {
  printf( "What file would you like to open\n" );
  // etc etc
}

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top