DIGIT-ARC read-only archive · snapshot: July 23, 2026

problems in visual c++

2 posts · originally from https://geek.digit.in/community/threads/problems-in-visual-c.164569/

A
abhishek39 Original post #1
Oct 11, 2012 at 6:16 PM
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
A
Nov 1, 2012 at 4:40 PM
i guess no one is interested in this...