Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › C++/C Programming › Learn how to code C++ || Day 3 - Variables and Date Types

Learn how to code C++ || Day 3 - Variables and Date Types

Posts 1–6 of 6 · Page 1 of 1
P0
P0SEID0N
Learn how to code C++ || Day 3 - Variables and Date Types
Lesson #3 - Variables/Data Types

The first thing i'm going to do is take a little experiment off here:
I want you to remember:
A = 6
B = 9
C = 3
D = 3
A + D = 9
E = A + D
C = E
E - 6 = B

Now what does A + B x C + E equal? Finding it a bit hard to remember? Thats why we have Variables.
What you have just done with your memory is the same as what a computer can do with variables. The same process can be done in C++ like this:
Code:
A = 6
B = 9
C = 3
D = 3
E = A + D
C = E
E - 6 = B
We can define a variable as a portion of memory to store a determined value. Think about it as a small block of memory, you can write on it, erase it, make it bigger or smaller, but all the time just calling it by its identifier.

The identifiers in that example were all single letters, A, B, C, D and E. Spaces or punctuation marks or symbols cannot be part of an identifier. Only letters, digits and single underscore characters are valid. Variable identifiers always have to begin with a letter or an underscore.

Something else that you have to consider when inventing your own identifiers is they cannot match any keyword of the C++ language or your compiler's specific ones, which are reserved keywords.
Standard reserved keywords are:
[php]
asm, auto, bool, break, case, catch, char, class, const, const_cast, continue, default, delete, do, double, dynamic_cast, else, enum, explicit, export, extern, false, float, for, friend, goto, if, inline, int, long, mutable, namespace, new, operator, private, protected, public, register, reinterpret_cast, return, short, signed, sizeof, static, static_cast, struct, switch, template, this, throw, true, try, typedef, typeid, typename, union, unsigned, using, virtual, void, volatile, wchar_t, while[/php]

Additionally, alternative representations for some operators cannot be used as identifiers since they are reserved words under some circumstances:

[php]and, and_eq, bitand, bitor, compl, not, not_eq, or, or_eq, xor, xor_eq[/php]

Remember C++ is a case sensitive language so Identifier is not the same as identifier or iDentifier.
There are many data types that can store many different things. From integers(whole numbers) to Characters or Strings. Here is a list of some.
[IMG]http://i755.photobucke*****m/albums/xx191/_-_-_JAMES_-_-_/DataTypes.jpg[/IMG]

If we want to use a variable, we must first declare it. You do this by putting a valid data type followed by your identifier. For example:
[php]int cat;
char dog;[/php]

If you are going to declare more than one variable of the same type, you can declare all of them in a single statement by separating their identifiers with commas. For example:
[php]int a, b, c;[/php]
You DON'T need to do
[php]int a;
int b;
int c;[/php]

The integer data types char, short, long and int can be either signed or unsigned depending on the need. Signed types can represent both positive and negative values, unsigned types can only represent positive values (and zero).If we do not specify either signed or unsigned most compiler settings will assume the type to be signed.

An exception to this rule is the char type, which is considered a different data type from signed char and unsigned char. You should use either signed or unsigned if you intend to store numerical values in a char-sized variable.

Short and long can be used alone as type specifiers. Short is equivalent to short int and long is equivalent to long int. The following two variable declarations are equivalent:
[php]
short cat;
short int cat;
[/php]

Signed and unsigned may also be used in the same way.

We will now look at the scope of variables.
There are two types of variables we will look at Global and Local.
Global variables can be referred from anywhere in the code, even inside functions, whenever it is after its declaration.
The scope of local variables is limited to the block enclosed in braces where they are declared. If they are declared at the beginning of the body of a function their scope is between its declaration point and the end of that function. This means that if another function existed in addition to main, the local variables declared in main could not be accessed from the other function and the variables from the other function could not be accessed inside main.

When declaring a regular local variable, its value is automatically undetermined. But you may want a variable to store a value at the same moment that it is declared. In order to do that, you can initialize the variable. There are two ways to do this in C++:
[php]
int a = 6;

OR

int a (6)
[/php]



We are now going to use all this in a program:
Code:
#include <iostream>
using namespace std;
//you can declare global variables here
int rabbit = 1;
int main()
{
//you can declare local variables here
int dog = 3;
int cat (4);
cout << dog << endl;
cout << cat << endl;
cout << dog + cat << endl;
dog = rabbit;
cout << "we have now changed dog to rabbit" << endl;
cout << dog;
return 0;
}
The result should look like this:
[php]
3
4
7
We have now changed dog to rabbit
1
[/php]

Credits:
www.cplusplus.com
www.cprogramming.com
Me
#1 · edited 16y ago · 16y ago
KI
killashoota1
Nice. I was watching this guy's tuts on youtube but i might just switch to this. And 1 suggestion: Can you add more things into 1 day until you get to the more complicated things? Just asking. U dont have to. But again, nice guide. Keep it up
#2 · 16y ago
why06
why06
Good tutorial I would say, I learned something new. I did not know you could initialize like this:
Code:
int a (6)
About the length: I would say this is a good size. because though you only talk about one thing u go into quite a bit of detail about it and I feel that is best. Keep up the good work.

EDIT: Looking back I see most of this is partial copy and paste off of cplusplus.com, but you gave credit, and I think this is a good thing so no worries.
#3 · edited 16y ago · 16y ago
P0
P0SEID0N
Not really a straight copy and paste. Took me an hour to put this together and re-word it and then added some other stuff. I just stole their tutorial structure :]
#4 · 16y ago
why06
why06
Edited post: changed "straight" to "partial" sry bout that, but only partially.
#5 · 16y ago
P0
P0SEID0N
<3 Msg2Short.
#6 · 16y ago
Posts 1–6 of 6 · Page 1 of 1

Post a Reply

Similar Threads

  • Learn how to code C++ || Day 3 - Variables and Date TypesBy P0SEID0N in CrossFire Hack Coding / Programming / Source Code
    8Last post 16y ago
  • Learn how to code C++ || Day 4 - Input and Modifying VariablesBy P0SEID0N in C++/C Programming
    3Last post 16y ago
  • Learn how to code C++ || Day 4 - Input and Modifying VariablesBy P0SEID0N in CrossFire Hack Coding / Programming / Source Code
    0Last post 16y ago
  • Learn how to code C++ || Day 1 - CompilerBy P0SEID0N in CrossFire Hack Coding / Programming / Source Code
    14Last post 16y ago
  • Learn how to code C++ || Day 1 - CompilerBy P0SEID0N in C++/C Programming
    5Last post 16y ago

Tags for this Thread

None