How do a input a sentence as a variable? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

How do a input a sentence as a variable?

I've tried a few methods Char a; Char a(.); Char a{.}; The output only prints one character Char a[any number]; this allows no limit of words but does not allow spaces to create sentences I'd like something like Cout<<"you are a"<<a; //*outputs You are a wizard harry Thank you

16th Jan 2017, 11:51 AM
Yucheng
Yucheng - avatar
3 Respuestas
+ 3
you want to look into strings.
16th Jan 2017, 12:08 PM
jay
jay - avatar
+ 3
[] is usually an array. You want to use a string instead of a char as they are fundametally different and chars is not meant to be used like this.
16th Jan 2017, 12:39 PM
Alex
Alex - avatar
0
Also im curious as to know why there is no difference between the first three And what does the number in the [] in the fourth method represent. Tha
16th Jan 2017, 11:53 AM
Yucheng
Yucheng - avatar