hello
i was wondering if somebody could help me.
I'm having problems with the validation of
the below code. When i run it, it seems to
get stuck in the loop. The compiler i'm using
is Borland C++ 5.02

Any sugestions would be greatly appreciated
Dave

#include <stdio.h>
#include <stdlib.h >
#define array_size 10  /* Size of the array */
int error_checker_ints(int);

void main()
{
int menu_option = 0;


while ( menu_option != 8)
{
error_checker_ints(menu_option);
switch ( menu_option )
{
    case 1  :
            printf( "Input Array\n" );
                system("pause");/* pauses the program
                           until any key is pressed */
        system("cls");/* clears the screen */
        break;


        case 2  :
            printf( "Selection Sort\n" );
                system("pause");
                system("cls");
        break;


        case 3  :
            printf( "Straight Bubble Sort\n" );
                system("pause");
                system("cls");
                break;


        case 4  :
            printf( "Advanced Bubble Sort\n" );
                system("pause");
                system("cls");
            break;


        case 5  :
            printf( "Insertion Sort\n" );
                system("pause");
                system("cls");
                break;


        case 6  :
        printf( "Sorted Array\n" );
        system("pause");
                system("cls");
                break;


        case 7  :
                  printf( "Complexity of sort\n" );
                  system("pause");
                  system("cls");
                  break;

        case 8  :
                  printf( "Thank you good bye\n" );
                  system("pause");
                  system("cls");
                  break;


        default :
        printf( "wrong entry try again\n" );
                system("pause");
                system("cls");
                break;
            }
    }
}

/*FUNCTIONS*/
int error_checker_ints(int temp)
{
    printf("Please enter choose : ");
    while (scanf("%d", &temp) != 1)
        {
            while (getchar() != '\n');
                printf ("Try again: ");
        }
    return temp;
}

Edited 3 Years Ago by Dani: Formatting fixed

This article has been dead for over six months. Start a new discussion instead.