Search Results

Search found 1 results on 1 pages for 'buddyfox'.

Page 1/1 | 1 

  • C++ cin whitespace question

    - by buddyfox
    Programming novice here. I'm trying to allow a user to enter their name, firstName middleName lastName on one line in the console (ex. "John Jane Doe"). I want to make the middleName optional. So if the user enters "John Doe" it only saves the first and last name strings. If the user enters "John Jane Doe" it will save all three. I was going to use this: cin >> firstName >> middleName >> lastName; then I realized that if the user chooses to omit their middle name and enters "John Doe" the console will just wait for the user to enter a third string... I know I could accomplish this with one large string and breaking it up into two or three, but isn't there a simpler way to do it with three strings like above? I feel like I'm missing something simple here... Thanks in advance.

    Read the article

1