Line 17: After this cin, '\n' is still in the input buffer. You need to add after line 17:
cin.ignore (1000, '\n');
You also have a memory leak in your program. Each time through the loop, you allocate a new string at line 20. At line 36, you release string only if opcion is false (exit). You need to release string each time through the loop.
One should also note that gets is one of the most dangerous functions in the C library since it doesn't allow you to specify a buffer size. Use cin.getline if you insist on using C strings, or std::getline if you come to your senses and decide to use std::string.
Hi All,
cin.ignore() used to make input buffer clear(or empty).
after you get input from "cin" you will get your data but In addition, you will get a new line command too(because when you want to send data you will press enter(or Return) button and it will send a new line command(\n) to the cin buffer too, when you write cin.ignore(1000, '\n') or only cin.ignore() it will empty the buffer of cin(in first case it will search for '\n' and clear then but in 2nd one it will empty the buffer completely), if you did not do that you will have '\n' in your cin buffer and when you try to use gets() it will get '\n' and so it never wait for your input.
I think you should get answer of your question.
Have Nice Life.
EDIT:
as MiiNiaPaa said, it will ignoring them but in real its same as you did not enter any '\n' to the cin buffer , I am agree with MiNiPaa but i don't like make changes to the Main post so i said it in EDIT, Thank you MiiNiPaa , I should be careful about words :D