0

how do I assign a word to a cin variable

I know how to do int c and then do cin >> c but how do I make c a word.

22nd Oct 2020, 4:21 PM
kyle
kyle - avatar
5 odpowiedzi
+ 3
kyle here is a quick code as Jayakrishna🇮🇳 pointed out: #include <iostream> using namespace std; int main() { int x = 24; string y = "Stan"; string z; cin >> z; cout << y << " is " << x << " years old and his friend " << z << " is too" << endl; return 0; }
22nd Oct 2020, 5:39 PM
BroFar
BroFar - avatar
+ 1
Same way.. string c; cin>>c; c++ have string datatype which c don't have.
22nd Oct 2020, 4:25 PM
Jayakrishna 🇮🇳
+ 1
Wow this is from 9 months ago and now I feel I was stupid asking that question now that I've completed c++
13th Aug 2021, 2:47 AM
kyle
kyle - avatar
+ 1
kyle that is growth from crawling to running ..
13th Aug 2021, 3:03 AM
BroFar
BroFar - avatar
+ 1
Yes...
13th Aug 2021, 3:03 AM
kyle
kyle - avatar