i am writing a menu by using switch
however it is not successful
i typed the option 1; but it seems it could not recognize and output [Please enter again]. Then i can't input anything, the screen flashed away...
also is it a bit clumsy for the code?
besides, i have one more question
i've attached a printscreen,
i would like to know how can i make the words printed in center? [green circle]
thanks!
Code:
#include <stdio.h>
void mypause ( void )
{
printf ( "\n\nPlease press [Enter] to continue . . ." );
fflush ( stdout );
getchar();
}
main()
{
printf("%c%c 2007-2008",006,006);
printf("%14c%c\n",006,006);
printf("%c%c Hello",006,006);
printf("%18c%c\n\n",006,006);
printf("%c%c World",006,006);
printf("%18c%c\n",006,006);
printf("%c%c Welcome",006,006);
printf("%16c%c\n\n\n\n\n",006,006);
printf("%c%c merry christmas! ",006,006);
printf("%6c%c\n",006,006);
mypause();
printf("\n\n\nPlease choose your options [ 1-6 ]\n\n");
printf("|| 1.");
printf("%10c%c\n",'|','|');
printf("|| 2.");
printf("%10c%c\n",'|','|');
printf("|| 3.");
printf("%10c%c\n",'|','|');
printf("|| 4.");
printf("%10c%c\n",'|','|');
printf("|| 5.");
printf("%10c%c\n",'|','|');
printf("|| 6.");
printf("%10c%c\n",'|','|');
int options;
printf("\n\n\nOptions:");
scanf("%d",&options);
//after choosing
switch (options) {
case '1':
printf("u choose 1");
break;
case '2':
printf("u choose 2");
break;
case '3':
printf("u choose 3");
break;
case '4':
printf("u choose 4");
break;
case '5':
printf("u choose 5");
break;
case '6':
printf("u choose 6");
break;
default:
printf("Please enter again [ 1-6 ]");
}
system("PAUSE");
}