c menu

This is a discussion on c menu within the C Programming forums, part of the General Programming Boards category; in c i need to have a menu.
pretty much
blah blah blah
then after all that executes you prompt ...

So lets see why I am breaking out the red. When you make an array your arrays are going to be filled with undefined data at first, and they are also going to start at index 0. So they go from 0 to n-1. So if you declare an array like this:

Example:

Code:

char array[50];

Then you can access from 0 to 49 (which is 50 - 1). If you are only comparing one char of string a and one char of string b, why not just directly compare them?

&#37;c is one of the trickier to use scanf() flags. That is why you may have noticed that in my code I did not use it. Though mine would still suffer from the fact that it would accept ' ' as a the character the user typed.

Try this one, ihope this will help much!!!

Code:

#include<stdio.h>
main()
{
char b;//variable for loop to be test
int a;//variable for choice
do
{
statement seq;//write your menus here!!
printf("\n\nenter choice:");//ask for the user to choose one of your menu
scanf("%d",&a);
switch(a)
{
case 1:
{
statement seq;
break;
}
case 2:
{
statement seq;
break;
}
defeult:
{
printf("\n\ninvalid choice!!!");//tells the user that they enter invalid choice from the menu
}
}//end of switch
printf("\nDo you want to try another?\ninput y if yes:");//ask the user if he/she wants to try another
scanf("%s",&b);//addressing variable to be test, i used %s because string is much better to use than the character
}while(b=='y'||b=='Y');
return 0;
}//end of main block!!