I made a c++ program.
I used cin.getline() function so I could input a string from the user. But when I run the program it does not input anything nor gives me a change to input anything instead it goes to the next statemement.

For eg. this is my program

char name[10],occupation[10];
cout<<"Enter name";
cin.getline(name,10);
cout<<"Occupation?";
cin.getline(occupation,10);

Now when I am running the program, it does not allow me to enter name but I can enter occupation. If I put occupation first, then it won't enter it. This problem is not just with this particular program but with every program in which I used cin.getline(). I tried gets() but no luck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.