Page 1 of 5

Trying something basic and need help

Posted: Tue Jan 20, 2009 5:57 pm
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.

Re: Trying something basic and need help

Posted: Tue Jan 20, 2009 8:26 pm
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!!

Re: Trying something basic and need help

Posted: Tue Jan 20, 2009 8:28 pm
by Ginto8
Just wondering, why are you using stdafx.h? main() and all the functions really only require iostream. :|

Re: Trying something basic and need help

Posted: Tue Jan 20, 2009 9:49 pm
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.

Re: Trying something basic and need help

Posted: Tue Jan 20, 2009 9:50 pm
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.

Re: Trying something basic and need help

Posted: Tue Jan 20, 2009 10:37 pm
by Aeolus
No gyro. All i had to do was add that = sign and it was all good.

Re: Trying something basic and need help

Posted: Tue Jan 20, 2009 10:56 pm
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.

Re: Trying something basic and need help

Posted: Wed Jan 21, 2009 12:54 pm
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;

Re: Trying something basic and need help

Posted: Wed Jan 21, 2009 1:03 pm
by sparda
#include <gyrovorbis>

using namespace herpes;
Hahahahahahahaha :lol: !

Aeolus, now you might get banned by the almighty Falco, good luck.

Re: Trying something basic and need help

Posted: Wed Jan 21, 2009 1:14 pm
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.

Re: Trying something basic and need help

Posted: Wed Jan 21, 2009 3:59 pm
by Aeolus
haha how could i get banned for making a joke? I mean come on that was funny.

Re: Trying something basic and need help

Posted: Wed Jan 21, 2009 4:55 pm
by MarauderIIC
You wouldn't be :P

Re: Trying something basic and need help

Posted: Wed Jan 21, 2009 5:13 pm
by Aeolus
I know cause im the shit! lol

Re: Trying something basic and need help

Posted: Wed Jan 21, 2009 5:16 pm
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.

Re: Trying something basic and need help

Posted: Wed Jan 21, 2009 5:19 pm
by Aeolus
:lol: too funny.

Marauder you crack me up. Admin face?!? RUN AWAY!!!