C++ Win32 Console Tutorial 4 - Variables and Data Types

preview_player
Показать описание
Variables:

Hold data in memory
Are assigned a data type
The data can change throughout the program's operation
The data must be the same data type as assigned to the variables

Common Data Types:

string - Text "Hello World"
short - Integer -32,768 to 32,767
int - Integer -2,147,483,648 to 2,147,483,647
float - Floating Point 3.4 +/- 38
double - Floating Point 1.7 +/- 308
bool - Boolean true or false

Full List of Data Types:
Рекомендации по теме
Комментарии
Автор

lol, im sure you know this by now because im four months late but i feel like writing a response, the reason is because, assuming their name is composed of letters and not numbers, you would need a variable of a data type that holds letters. so you could either do a char array by doing,
const char *username = new char[20];
which would create an array of characters with a maximum length of 20,
or you could #include string, and just do

string username;

asfadasfa
Автор

So, if I wanted to put in a interger variable of "v" it would need to go after "int main()"?

calsonsur
Автор

Your the best! I have on question though. I want to ask the player their name so i put
int A; Then I have the player enter the integer as their name. What I would like to do is have a cout that says the name back to them but in the debugger the name comes back as something like -9371638372. Do you know how to fix this?

LemonzGaming
Автор

And I would also have to go: int v;, correct?

calsonsur