Trying something basic and need help

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

User avatar
Aeolus
Chaos Rift Regular
Chaos Rift Regular
Posts: 179
Joined: Fri Jan 16, 2009 2:28 am

Trying something basic and need help

Post by Aeolus »

Ok well im watching AntiRTFM episodes and im currently on episode 19. Well i take detailed notes in some regular college bound notebooks i have when i watch videos, read books, look at tutorials.

So basically before i write this code down as a example code for declaring voids i want to make sure it works. So i quickly drew out this code:

Code: Select all

/* This is the system boot section where it loads headers for the program. */

#include "stdafx.h"

#include <iostream>

using namespace std;

/* Declaration section of the program */

void function1()
{
	cout << "Function 1 loaded.\n";
}
void function2()
{
	cout << "Function 2 loaded.\n";
}
void function3()
{
	cout << "Function 3 loaded.\n";
}

/* Main function section */

int main()
{
	int thenumber 76;
	int playerguess;

	cout << "Lets play guess my number, type a number between 0-100.\n";
	cin >> playerguess;

	if (playerguess == thenumber)
		cout << "You won!\n";
	else
		cout << "Try again...\n";

	function1();
	function2();
	function3();

	char f;
	cin >> f;
	return 0;
}
The code basically shows how to declare the voids, if im doing it wrong tell me, and has a little number game tutorial. So i go to compile and i get this error:

Code: Select all

1>------ Build started: Project: Example of a declared code, Configuration: Debug Win32 ------
1>Compiling...
1>stdafx.cpp
1>Compiling...
1>AssemblyInfo.cpp
1>Example of a declared code.cpp
[color=#FF0000]1>.\Example of a declared code.cpp(28) : error C2143: syntax error : missing ';' before 'constant'[/color]
1>Generating Code...
1>Build log was saved at "file://c:\Users\Kyle\Documents\Visual Studio 2008\Projects\Example of a declared code\Example of a declared code\Debug\BuildLog.htm"
1>Example of a declared code - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Ive read over my code, and the error about 4 times now and i do not get where my 'constant' is.
Hyde from That 70's Show wrote:Woman are like muffins... Once you have a muffin you will do anything to have another muffin... And they know that.
User avatar
KuramaYoko10
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 55
Joined: Fri Oct 31, 2008 8:02 pm

Re: Trying something basic and need help

Post by KuramaYoko10 »

If your problem is just compiling, it is pretty simple....

You forgot to put an equal sign here

Code: Select all

int main()
{
   int thenumber = 76;  //Here
   int playerguess;

.
.
.
Now... if you want to make it a constant, I think you should declare it before the main function and with capitalized letters with preference xD

Code: Select all

const int THE_NUMBER = 76;

int main()
{
.
.
.
}
Have fun!!
Type a message here!!
[b][color=#BF0000]MarauderIIC[/color][/b] wrote:"Never" is never true in programming.
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: Trying something basic and need help

Post by Ginto8 »

Just wondering, why are you using stdafx.h? main() and all the functions really only require iostream. :|
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
Aeolus
Chaos Rift Regular
Chaos Rift Regular
Posts: 179
Joined: Fri Jan 16, 2009 2:28 am

Re: Trying something basic and need help

Post by Aeolus »

idk lol i dont know much about stdafx.h and so i just put it in there for the lawls i guess.

Thanks Kurama.
Hyde from That 70's Show wrote:Woman are like muffins... Once you have a muffin you will do anything to have another muffin... And they know that.
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Trying something basic and need help

Post by Falco Girgis »

You're going to need that if your projects requires precompiled headers. Get rid of it and check if it bitches at you.
User avatar
Aeolus
Chaos Rift Regular
Chaos Rift Regular
Posts: 179
Joined: Fri Jan 16, 2009 2:28 am

Re: Trying something basic and need help

Post by Aeolus »

No gyro. All i had to do was add that = sign and it was all good.
Hyde from That 70's Show wrote:Woman are like muffins... Once you have a muffin you will do anything to have another muffin... And they know that.
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Trying something basic and need help

Post by Falco Girgis »

Oh, I know that's not the problem, but it was suggested that you get rid of it, because you don't need it. I'm just saying that it might not compile without it, depending on your project settings.
User avatar
Aeolus
Chaos Rift Regular
Chaos Rift Regular
Posts: 179
Joined: Fri Jan 16, 2009 2:28 am

Re: Trying something basic and need help

Post by Aeolus »

Oh, hey i got a question. Say im working on a huge server emulator for a game. And it has quite a few errors.

Will this line of code fix all errors?

Code: Select all

#include <gyrovorbis>

using namespace herpes;
Hyde from That 70's Show wrote:Woman are like muffins... Once you have a muffin you will do anything to have another muffin... And they know that.
User avatar
sparda
Chaos Rift Junior
Chaos Rift Junior
Posts: 291
Joined: Tue Sep 23, 2008 3:54 pm

Re: Trying something basic and need help

Post by sparda »

#include <gyrovorbis>

using namespace herpes;
Hahahahahahahaha :lol: !

Aeolus, now you might get banned by the almighty Falco, good luck.
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Trying something basic and need help

Post by MarauderIIC »

sparda wrote:Aeolus, now you might get banned by the almighty Falco, good luck.
I seriously doubt it.

Aeolus: You'd have to paste it into every .cpp file. But if you did that, you would magically get code like this

Code: Select all

	if(Play.partySystem.getPartyMember(relativeCursor).equip.right != -1)
		ItemSys.itemList[Play.partySystem.getPartyMember(relativeCursor).equip.right].img->Draw(0, 340, 122, 42, 32, 32, 0);
	if(Play.partySystem.getPartyMember(relativeCursor).equip.left != -1)
		ItemSys.itemList[Play.partySystem.getPartyMember(relativeCursor).equip.left].img->Draw(0, 388, 122, 42, 32, 32, 0); 
	if(Play.partySystem.getPartyMember(relativeCursor).equip.armor != -1)
		ItemSys.itemList[Play.partySystem.getPartyMember(relativeCursor).equip.armor].img->Draw(0, 436, 122, 42, 32, 32, 0); 
But if you did

Code: Select all

#include <marauderiic>
using namespace awesome;
Then you would get code like

Code: Select all

	const Equipment& curEquip = Play.partySystem.getPartyMember(relativeCursor).equip;
	SpriteRenderer& spriteRenderer = SpriteRenderer::getInstance();

	if(curEquip.right != -1)
		spriteRenderer.draw(*ItemSys.itemList[curEquip.right].img, false, 340, 122, 42, 32, 32, 0);

	if(curEquip.left != -1)
		spriteRenderer.draw(*ItemSys.itemList[curEquip.left].img, false, 388, 122, 42, 32, 32, 0); 

	if(curEquip.armor != -1)
		spriteRenderer.draw(*ItemSys.itemList[curEquip.armor].img, false, 436, 122, 42, 32, 32, 0); 
Although if you leave it included long enough, the magic numbers (122, 42, 32, 32, 0) will eventually disappear.

Okay, I've brought that up four times in the last two days, I guess I better leave it be now, before he finds something to rag on me about.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
Aeolus
Chaos Rift Regular
Chaos Rift Regular
Posts: 179
Joined: Fri Jan 16, 2009 2:28 am

Re: Trying something basic and need help

Post by Aeolus »

haha how could i get banned for making a joke? I mean come on that was funny.
Hyde from That 70's Show wrote:Woman are like muffins... Once you have a muffin you will do anything to have another muffin... And they know that.
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Trying something basic and need help

Post by MarauderIIC »

You wouldn't be :P
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
Aeolus
Chaos Rift Regular
Chaos Rift Regular
Posts: 179
Joined: Fri Jan 16, 2009 2:28 am

Re: Trying something basic and need help

Post by Aeolus »

I know cause im the shit! lol
Hyde from That 70's Show wrote:Woman are like muffins... Once you have a muffin you will do anything to have another muffin... And they know that.
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Trying something basic and need help

Post by MarauderIIC »

Aeolus wrote:I know cause im the shit! lol
JUST LIKE YOUR POSTS OH SNAP
Hold on let me put my mature administrator face on again. Slipped there.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
Aeolus
Chaos Rift Regular
Chaos Rift Regular
Posts: 179
Joined: Fri Jan 16, 2009 2:28 am

Re: Trying something basic and need help

Post by Aeolus »

:lol: too funny.

Marauder you crack me up. Admin face?!? RUN AWAY!!!
Hyde from That 70's Show wrote:Woman are like muffins... Once you have a muffin you will do anything to have another muffin... And they know that.
Post Reply