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 › Declaring variables. I r newb.

Declaring variables. I r newb.

Posts 1–15 of 36 · Page 1 of 3
crushed
crushed
Declaring variables. I r newb.
Hallopeople. :O

I'm new to C, and C++. Reading a pretty old book as well, written...no idea when. Anyways, the book is by Sam A. Abolorous. It's called 'Learn C In Three Days'. Possible, not possible, I don't know considering I wanna take my time with programming and not burn through it. Rushing it, learning it, then when you try to apply it to something else, your like what? No, I wanna learn it properly so I can apply it wherever needed.

Anyways, back to the question. o_o So the book has a code...and it gives an example of declaring variables. I tried inputting that code, TRIED modifying it and still no luck. I get errors. I'll post the code I tried. Keep in mind I used MICROSOFT VISUAL C++.

The code from the book.

Code:
*****#include <stdafx.h>
#include <stdio.h>
main()
{
	//Declarations.
	int a;
	float b;
	//Assignment.
	a=1024;
	b=512;
	//Display output.
	printf("%d\n",a);
	printf("%f\n",b);
}
Thanks to whoever helps me out. ^_^

EDIT: I dunno how to use the code thingy...so I apologize about that. ._.
EDIT: Thanks Zeco for teaching me how to put the code.

ALRIGHT, whee. I used DevC++, and it worked. I somewhat changed the script so it pauses for a while. Thanks Why06 for the tip. FINAL:
Code:
#include <stdio.h>
#include <conio.h>

int main()
{
	//Declarations.
	int a;
	float b;
	//Assignment.
	a=1024;
	b=512;
	//Display output.
	printf("%d\n",a);
	printf("%f\n",b);
    getch();
}
#1 · edited 16y ago · 16y ago
ZE
zeco
Don't really see anything wrong with that :/, except maybe putting int, infront of Main. Never really tried to see if the compiler assumes a void in that situation.

By the way, congratulations on being the most respectably new person to come to this site in Days, maybe weeks =)

And to use the code box thingy, put your code between a (code) and a (/code), except replace the regular brackets with square brackets [ ] [/ ]
#2 · 16y ago
crushed
crushed
Quote Originally Posted by zeco View Post
Don't really see anything wrong with that :/, except maybe putting int, infront of Main. Never really tried to see if the compiler assumes a void in that situation.

By the way, congratulations on being the most respectably new person to come to this site in Days, maybe weeks =)

And to use the code box thingy, put your code between a (code) and a (/code), except replace the regular brackets with square brackets [ ] [/ ]
Ah, so I see. The code isn't the fault. I've downloaded DevC++, so I'll try inputting it in that tommorrow. It's time for me to sleep. Almost 2 AM! XD

Thank you for letting me know how to use the code, I'll try it. And thanks for the welcoming gesture as well.
#3 · 16y ago
howl2000
howl2000
Code looks well enough to me. Too lazy to compile it.

Before your main function some compilers require you put. int or void
example: void main()


also you might want to get into the habbit of putting decimals in float variables.
example: like 5.0 etc

those would probably make my compiler take it. visual studio 2008
#4 · 16y ago
GE
geebes888
Same i just recently started to learn c++ so i can't help u but it looks like they already have.
#5 · 16y ago
ZE
zeco
It helps if you post the errors because those help immensely =)
#6 · 16y ago
why06jz
why06jz
Hmmm.... well I just compiled it as a C file in my Dev-C++ compiler and it seems to have worked. All I had to do was comment out the first #include statement. Weird. I didn't know the compiler would default like that in the case of main().

Another problem is that it flashes up on the screen really fast so you can't see it. So I would include this system("pause"); on the last line so you can see what you wrote.
#7 · 16y ago
BO
BooYa
using namespace std; ? Don't know if it's needed with a printf statement
#8 · 16y ago
ZE
zeco
Quote Originally Posted by BooYa View Post
using namespace std; ? Don't know if it's needed with a printf statement
It isn't. =)
#9 · 16y ago
PI
Pixipixel_
Quote Originally Posted by BooYa View Post
using namespace std; ? Don't know if it's needed with a printf statement

Nah it's useless. If you use cout << "blabla"; (C++) use using namespace std;
printf is in C, not in C++ wich use cout.
#10 · 16y ago
crushed
crushed
Whee, thanks to everyone that replied!
I'll try the script now with some modfications listed above in Dev C++ now. I was using MS Visual C++ earlier.

EDIT: My very first own attempt at coding an assignment from the book. Kinda happy considering I didn't have to use the book for it.
Code:
#include <stdio.h>
#include <conio.h>
int main()
{
    //Delcarations.
    double number;
    //Assignments
    number=3.45678;
    //Output
    printf("%.0f\n", number);
    printf("%.2f\n", number);
    getch();
}
#11 · edited 16y ago · 16y ago
Hell_Demon
Hell_Demon
Congratulations
Adding you to my respected list
#12 · 16y ago
crushed
crushed
Quote Originally Posted by Hell_Demon View Post
Congratulations
Adding you to my respected list
Thank you very much! And I'm honored to be on your respect list.
I'm glad, considering even though I'm new, people are friendly and really helpful. :3

Oh, and just posting how far I am along now. I've just finished learning Pointers.
Code:
#include <stdio.h>
#include <conio.h>
int main()
{
    //Declarations.
    char *a, *b;
    //Assignment.
    a="Hello Again, I'm being pointed to the character a!";
    b="Hello Again, I'm the pointer for the character b!";
    printf("%s\n%s\n",a,b);// NTS: For every character(a,b), add a string spec.
    getch();
}
#13 · 16y ago
ZE
zeco
Quote Originally Posted by crushed View Post
Thank you very much! And I'm honored to be on your respect list.
I'm glad, considering even though I'm new, people are friendly and really helpful. :3

Oh, and just posting how far I am along now. I've just finished learning Pointers.
Code:
#include <stdio.h>
#include <conio.h>
int main()
{
    //Declarations.
    char *a, *b;
    //Assignment.
    a="Hello Again, I'm being pointed to the character a!";
    b="Hello Again, I'm the pointer for the character b!";
    printf("%s\n%s\n",a,b);// NTS: For every character(a,b), add a string spec.
    getch();
}
Pointers are quite fun =). Just be careful with them. Pointers are really cool, but if you aren't careful stuff could blow up ^^
#14 · 16y ago
crushed
crushed
Quote Originally Posted by zeco View Post
Pointers are quite fun =). Just be careful with them. Pointers are really cool, but if you aren't careful stuff could blow up ^^
That's true. LOL, It just makes everything alot easier. After I'm done memory locations, I'm gonna try to code something that I've learnt from Chapter 1 overall. Just as a review, look at my notes to see what I've learnt and yee.

EDIT:
Uh. o_o Question for anyone that's reading this atm!
Code:
#include <stdio.h>
#include <conio.h>
int main()
{
    char *a;
    a="Hello again ";
    printf("%s\n" ,a);
    printf("%c\n" ,*a);
    printf("%d\n" ,a);
    printf("%p\n" ,a);
    printf("%d\n", *a);
    getch();
}
So I'm doing examining Memory Locations atm, and the book I'm reading gives that code as an example to do. I wrote it word for word, exactly how it should be and yet I get a different answer.
The output is supposed to be,
Code:
Hello again
H
168
00A8
72
Yet I'm getting...
Code:
Hello again
H
4206592   <-----=Incorrect
00403000  <----- =Incorrect
72
Does anyone know what I did wrong? Or can anyone explain what I'm doing wrong?
Much appreciated, thanks!.
#15 · edited 16y ago · 16y ago
Posts 1–15 of 36 · Page 1 of 3

Post a Reply

Similar Threads

  • Notice: To spamming newbs.By Dave84311 in General
    0Last post 20y ago
  • LOL @ Amazon those newbsBy SATANICAT in General
    16Last post 20y ago
  • NEWBS SIG PLS :dBy SATANICAT in Help & Requests
    3Last post 19y ago
  • newb question =(By fable741 in WarRock - International Hacks
    3Last post 19y ago
  • i no y k2 r newbs =)By jkmacnak in WarRock - International Hacks
    2Last post 19y ago

Tags for this Thread

#c++#declaring#newb#turtles.#variables