Help With C++ Very Basic

Status
Not open for further replies.

mrserv0n

Baseband Member
Messages
38
Hey I am doing this tutorial for a program for class, I know nothing of C++ so bear with me.

This project is set to create console application.

Here is the code

/* '01 Main.cpp' */
#include <stdafx.h>

main (void)
{
/* Variable declarations*\
unsigned char Age;
long StartEnergy;
char CharacterType;

/* Get the Information *\
std::cout << "What is your Character's Age?: ";
std::cin >> Age;
std::cout << "How much start Energy?: ";
std::cin >> Start Energy;
std::cout << " Character Race?: ";
std::cin >> Character Race;

/*Show the information*\
std::cout << "Your chacter is " << Age << " years old." << std::endl;
std::cout << "Has " << StartEnergy << " of starting energy." << std::endl;
std::cout << "And its race is " << CharacterType << *.* << std::endl;
return 0;
}


Ok now whenever I go to Debug or Run it it just says "filename.exe not found" Well how do I get to preview my little text program? or run it period for that matter.
 
What compiler / program are you using? Sounds like it's not compiling, hence no file (filename.exe) to run?
 
I an using Visual Studio 2005. I am not sure about a compiler. I mean I shouldnt have to compile this just to see it, its just a text dos console. Basically just like the simple Hello world tutorial. Which does run by the way.


As for second poster. Can you be more specific what syntax error do you see? VS doesn't seem to say there are any. And the code is taken straight from a college text book word for word...
 
Don't know why I didn't see this the first time--this is most likely the problem:

Your comments:

/* '01 Main.cpp' */
/* Variable declarations*\
/* Get the Information *\
/*Show the information*\

Open: /*
Close: */

And since after the variable declaration comment, the comment is never closed--well, there's no program there. :)

So it should be:
Code:
/* '01 Main.cpp' */
#include <stdafx.h>

main (void)
{
/* Variable declarations*\
unsigned char Age;
long StartEnergy;
char CharacterType;

/* Get the Information */
std::cout << "What is your Character's Age?: ";
std::cin >> Age;
std::cout << "How much start Energy?: ";
std::cin >> Start Energy;
std::cout << " Character Race?: ";
std::cin >> Character Race;

/*Show the information */
std::cout << "Your chacter is " << Age << " years old." << std::endl;
std::cout << "Has " << StartEnergy << " of starting energy." << std::endl;
std::cout << "And its race is " << CharacterType << *.* << std::endl;
return 0;
}

I don't have VS to test, right now. >.>

As well, if there are other syntax errors, now VS should tell you.
 
oh Jeez thank you so much. I can see how that was easy to overlook for even myself. I swear I have stared at it for hours lol. Thank you so much Ill try it.
 
And where it says
Code:
std::cin >> Character Race;
you would want it to say "CharacterType" instead.
 
Thank you yea I found a couple other errors too but got it working.

In my book for school it says #include <stdafx.h>

However I got tan error saying not found. When I switched it to #include <iostream> it worked fine. What is stdafx.h and why does my college book use that?
 
Stdafx.h is outdated, Visual Studio 2005 uses the newer standard, and that is iostream, which you used.
 
Ok one last question when I run this program in Visual C++ 6.0 it works fine. I copy the same code to VS 2005 and I get this error

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
 
Status
Not open for further replies.
Back
Top Bottom