I'm writing code for a c-string input and output, but when I go for the output, it skips the first word and outputs all the other words after that.
heres the code:
cout << " Input a a phrase with a maximum 30 characters: ";
cin.ignore();
cin >> sphrase;
getline(cin,sphrase);
cout << " The phrase inputed was: " << sphrase << endl;
cin >> sphrase takes the first word and puts it in sphrase and leaves the rest in the buffer. getline(cin, sphrase) takes the rest of the words from the buffer and puts them in sphrase which is why you lose the first word.