Respuesta :
Often it is unwanted that cin doesn't read until a newline character, but in stead separates input at the space. For this exercise that's actually very convenient:
cin >> userWord;
cin >> userNum;
cout << userWord << "_" << userNum;
This will do the trick.
You will want to include <iostream> and <string>.
cin >> userWord;
cin >> userNum;
cout << userWord << "_" << userNum;
This will do the trick.
You will want to include <iostream> and <string>.
#include <iostream>
#include <string>
using namespace std;
int main() {
string word = "";
int userNum = 0;
cout<<"Enter a word: ";
cin>>word;
cout<<"Enter a number: ";
cin>> userNum;
cout<<word<<"_"<<userNum<<endl;
return 0;
}