I need to get an input in a console application. Normally, this would be a simple task with scanf (I know scanf is old, but I'm learning in my University, and they teach us that, looks like later we will use iostream). So my problem begins that I need to ask for a name, last name and phone number, but that name should contain spaces.
Normally, I use the following line:
But under ubuntu this doesn't work, so I started looking for other functions, or workarounds:scanf("%[^\n]", &myvariable);
gets(); works nice, but for some reason, I have three gets' and the first is skipped, even if I use "fflush(stdin);".gets(&myvariable);
So my question, what's the best way to eat an empty space from the input? either windows or linux with C.
Thanks in advance.



Adv Reply





Bookmarks