Shouldn't this work? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
28th Dec 2018, 7:29 PM
Jeremy Cruz
Jeremy Cruz - avatar
4 Answers
+ 6
You must specify array size if you're going to put values after you declare it.
28th Dec 2018, 7:55 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 6
Because char is one letter You can use one of these codes to print more letters but 'cin' stops after space so 'ab ab' prints 'ab' Check this if you want spaces in your input too https://stackoverflow.com/q/5838711/9132046 void myfunc(){ char str[100]; cin >> str; cout << str; } void myfunc(){ string str; cin >> str; cout << str; }
28th Dec 2018, 8:12 PM
Mert Yazıcı
Mert Yazıcı - avatar
0
Even if i do that i just get the first letter
28th Dec 2018, 7:57 PM
Jeremy Cruz
Jeremy Cruz - avatar
0
K thanks
28th Dec 2018, 8:13 PM
Jeremy Cruz
Jeremy Cruz - avatar