Currently Being ModeratedNov 13, 2012 7:17 AM (in response to quiban92)
You are mixing up two different ways of getting user input.
1. getline -- a standard <stdio> function which reads user input and a return;
2. cin -- a C++ <iostream> function which reads user input and a return.
See http://crasseux.com/books/ctutorial/getline.html and http://www.htmlhelpcentral.com/messageboard/showthread.php?4359-C-Tutorial-1-cou t-cin for the proper way to use either one of them; you cannot use both in the same command.
i dont know what to do i have looked on the internet but i havent found anything to solve this problem......
Those two links were the very first hits on a search for "getline tutorial" and "cin tutorial".
Currently Being ModeratedNov 13, 2012 6:14 PM (in response to Jongware)
I managed to solved the problem switching the cin.getline with simple cin.
but i still couldnt find out why does cin.getline asks for double enter on Xcode i wrote the same code on Scite and it doesnt behave the same.....
Also i dont undestand what you mean by mixing up two different ways of getting user input.
im taking computer science and the told us that there are different ways to get input from the user and a few that we often use are cin , cin.get , cin.getline.
Currently Being ModeratedNov 14, 2012 3:30 AM (in response to quiban92)
Apologies about my 'getline' mishap -- it's a valid cin function after all.
Some further research led me to this: cin.getline(dest, count) reads up to count characters and ignores everything that follows. Perhaps your NAME_LENGTH value is 4? In that case, cin.getline is done right after you entered "Juan", and the hard return is left dangling for the next command. (See http://www.cplusplus.com/reference/iostream/istream/getline/ for a better description.)
I found it's commonly suggested to add an 'ignore' right after each getline, to prevent any unwanted characters in the next input line.