I want to declare a variable as a string so that I could have the user enter their name. If I do this:
char a[10];
When the user enters their name, only the first letter shows up. What am I missing?
How do I use a string in C++?
u can use string datatype or using char it can be done
do
main()
{
char a[];
cin%26gt;%26gt;a;
cout%26lt;%26lt;a;
}
it is the way
Reply:you just input
System.out.print("Insert text here");
This is a basic string of text...
Reply:A character array as a string is not C++, it's an old way of having a cstring. If you want a C++ string you need:
#include %26lt;string%26gt;
string name; //declaration
cin %26gt;%26gt; name; //the user enters their name.
Hope this helps..
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment