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 › Why does this code work?

Why does this code work?

Posts 1–5 of 5 · Page 1 of 1
Nissen1502 is back
Nissen1502 is back
Why does this code work?
So i'm learning c++ by reading a book, and i started messing around with the code. This is how it usually looks like:
{
using namespace std; //for cout
std::cout << "How are you?"; //writes to display
std::cout << std::endl; //goes to next line
std::cout << "I'm fine atleast"; //writes to display
cin.get(); //makes the program stay on the screen until enter is pressed
return 0; //terminate main
}

Now that seems perfectly fine which it is, now why does this work?
{
using namespace std; //for cout
std::cout << "How are you?"; //writes to display
std::cout << std::endl; //goes to next line
std:cout << "I'm fine atleast"; //writes to display
cin.get(); //makes the program stay on the screen until enter is pressed
return 0; //terminate main
}
I removed one of the : from the std:cout << "I'm fine atleast";
I tried to remove it from any of the other std::cout but then the build got errors, someone please explain
#1 · 13y ago
ER
ERGaergaergaergaergearg
I'd really appreciate if you put the code in [CODE] so it's more easy to read it.

Anyway, to the code...

First of all, if you have typed
Code:
using namespace std;
There's no need for you to type:
Code:
std::cout << "How are you?";
This is enough:
Code:
cout << "How are you?";
I wrote a much more cleaner version of the code here:

Code:
#include <iostream> // Importing the library for this to work

using namespace std; // The standard namespace instead of using std:: infront of cout. Dont use both.

int main() // Always have a main function
{

	cout << "How are you?" << endl;
	cout << "I'm fine atleast";
	cin.get();
	return 0;

}
Just a bit curious, What book are you reading?

Oops, Almost forgot to ask.. What kind of compiler are you using?
#2 · edited 13y ago · 13y ago
Nissen1502 is back
Nissen1502 is back
Quote Originally Posted by gresan6 View Post
I'd really appreciate if you put the code in [CODE] so it's more easy to read it.

Anyway, to the code...

First of all, if you have typed
Code:
using namespace std;
There's no need for you to type:
Code:
std::cout << "How are you?";
This is enough:
Code:
cout << "How are you?";
I wrote a much more cleaner version of the code here:

Code:
#include <iostream> // Importing the library for this to work

using namespace std; // The standard namespace instead of using std:: infront of cout. Dont use both.

int main() // Always have a main function
{

	cout << "How are you?" << endl;
	cout << "I'm fine atleast";
	cin.get();
	return 0;

}
Just a bit curious, What book are you reading?

Oops, Almost forgot to ask.. What kind of compiler are you using?
I actually know that i dont have to write it like that i just tested it for the case of testing, you know, exploring makes you better at stuff.
I'm reading C++ Primal Plus 6th edition.
I'm using Microsoft Visual C++ 2010 Express

Also, if interested, here's the actual code i wrote:
Code:
#include <iostream> //includes input/output, must use for cout and cin functions
int main() //Main is a MUST unless it's a DLL
{
	using namespace std; //for cout
	cout << "How are you?"; //writes to display
	cout << std::endl; //goes to next line
	cout << "I'm fine atleast"; //writes to display
	cin.get(); //makes the program stay on the screen until enter is pressed
	return 0; //terminate main
}
#3 · edited 13y ago · 13y ago
AT
atom0s
The "why doesn't this work" is because of this line:
std:cout << "I'm fine atleast"; //writes to display

You are missing a : in the std:: namespace prefix.
#4 · 13y ago
Nissen1502 is back
Nissen1502 is back
Quote Originally Posted by atom0s View Post
The "why doesn't this work" is because of this line:
std:cout << "I'm fine atleast"; //writes to display

You are missing a : in the std:: namespace prefix.
it works, thats why im wondering lol

edit: Nvm, found out why. /thread
#5 · edited 13y ago · 13y ago
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

  • Why does this not work?By extremehack in Combat Arms Hack Coding / Programming / Source Code
    8Last post 16y ago
  • Why does this inherited method work?By Laslod in C# Programming
    18Last post 13y ago
  • Why does this dont work?By skulhead in WarRock Hack Source Code
    11Last post 15y ago
  • Does This Code WOrks (NoReloadCode)By vayerman in CrossFire PH Help
    8Last post 14y ago
  • Why does this dont work?By skulhead in WarRock Hack Source Code
    10Last post 15y ago

Tags for this Thread

None