C++ Programming
char a = 'G'; this is if you want to store only one character
char name[20]; this will store an array that has 20 spaces in it so you can save something like 'Richmond' so maybe call the array
char city[10]='Richmond' since there is a blank space in the array cause richmond doesnt take all 10 then the last space will have a null character. So really in an array of 20 there is only space for 19 cause the last place will be occupied by a null character.
int a;
a = 10;
a = 40;
thats how you declare and assign and update wiht a simple variable
for a string to be assigned there needs to be an array declared first...
char name[20];
name='Richmond'; you cant just put after...
char name[20]='Richmond'; this si the correct way of assigning a string to a array
OR you can use a cin to complet the assign
char city[20];
cout<<"type your city";
cin>>city;
cout<
/* sets off multiple lines off as a comment */
// will set just a single line off as a comment...
2^64-1 is the current limit of the integer and if you need to go beyond that use a different data type
Escape character - a character that the compiler has set for a special purpose
\n - New line
\t - Horizontal tab
\b - Backspace
\r - Carriage Return
\a - makes a beep noise out of the machine...
char name[20]; this will store an array that has 20 spaces in it so you can save something like 'Richmond' so maybe call the array
char city[10]='Richmond' since there is a blank space in the array cause richmond doesnt take all 10 then the last space will have a null character. So really in an array of 20 there is only space for 19 cause the last place will be occupied by a null character.
int a;
a = 10;
a = 40;
thats how you declare and assign and update wiht a simple variable
for a string to be assigned there needs to be an array declared first...
char name[20];
name='Richmond'; you cant just put after...
char name[20]='Richmond'; this si the correct way of assigning a string to a array
OR you can use a cin to complet the assign
char city[20];
cout<<"type your city";
cin>>city;
cout<
/* sets off multiple lines off as a comment */
// will set just a single line off as a comment...
2^64-1 is the current limit of the integer and if you need to go beyond that use a different data type
Escape character - a character that the compiler has set for a special purpose
\n - New line
\t - Horizontal tab
\b - Backspace
\r - Carriage Return
\a - makes a beep noise out of the machine...
0 Comments:
Post a Comment
<< Home