plz i need to know all variables especially the variable for text i knoe CHAR but it only displays 1 letter plz email me with the answer
plz i need to know all variables especially the variable for text i knoe CHAR but it only displays 1 letter plz email me with the answer
me
Do you mean functions to display text? or declaring variables that hold strings?
bool
char (signed or unsigned)
short (signed or unsigned)
int (signed or unsigned)
long (signed or unsigned)
float
double
long double
For text you use either an array of char or the string class offered by the standard library in the <string> header.
To display more than one character you use an array of char, thus...
char x; // single character
char y[10]; // array for 9 character string
... a string like this must have a NULL character as it terminator, so the array must always be one character longer than the string you wish to show.
it dn display spaces like of i use
#include <iostream.h>
int main()
{
cout<<"Welcome to shady's first c++ program\n";
char name[90];
cout<<"wut's ur name?\n";
cin>>name;
cout<<"Welcome "<<name<<"\n";
}
and type name secondname third name it only displays the name
Originally posted by adrianxw
To display more than one character you use an array of char, thus...
char x; // single character
char y[10]; // array for 9 character string
... a string like this must have a NULL character as it terminator, so the array must always be one character longer than the string you wish to show.
cin's >> operator stops reading at spaces. If you want to have whitespace in your input you can use getline
Code:cin.getline(name, sizeof (name));