I am trying to take in inputs from the user for one of my projects.

cout<<"Enter Event Name (enter 'exit' to quit) ::";
    cout<<"Enter Type Of Event (eg: Dance, Music, 'exit' to quit) ::";
        return 0;

here the line


will not execute, and the program jumps to the next input statement.

I tried replacing gets with, cin.getline but still have the same problem,

using cin solves the problem, but i need to take in a string so cin wont work.

Please help me with this, I am at an emergency, ...please help
Thanks In Advance

Using gets() is usually a bad idea from the start (See this page for more information), but this problem is usually caused by stray characters still present in the buffer. gets() will simply take those characters as input and it seems as though your program is skipping input. It can be fixed by flushing the buffer(input stream). Just add cin.ignore(); before your gets() statement.

If you need better methods to do the same, then take a look at Narue's article (which incidentally, is a sticky right at the top of the forum)

A quick suggestion, though: Use std::string instead of char arrays, as many things (including input and comparison) are made easier.

commented: Great suggestions :) +33