problems in visual c++

abhishek39

Broken In
i have written a program which contains the following function 'input' which is a part of a class 'ai' in the same program:

PHP:
void ai::input()
{aa:cout<<"user:";
    
	gets(user_input);



     if(strcmpi(user_input,"bye")==0)
    {
        cout<<"bye";

        exit(0);
    }
    else
    process();

    goto aa;

}


here the function takes user_input and calls process() for the left part till user types 'bye'.
but the problem is when first time the function is called, while running the program it some how skips 'gets(user_input);' goes to process() hence the whole program runs with an empty 'user_input'
the i again returns to the function input ....
the input runs again from the label 'aa'. and this time the program runs fine, it also executes the statement 'gets(user_input);' .
the same happens with one more function 'getit()' (a part of class 'word') in the same program.
PHP:
void getit()
     { cout<<"enter question\n";
        gets(ques);
        cout<<"enter it's answer\n";
        gets(ans);
        }

here it skips displays "enter question" then skips gets(ques); the displays "enter it's answer" the takes input for ans.
i have checked the program i code blocks and visual studio.
what may be the problem
 
Top Bottom