Sign in to follow this  

error

This topic is 3592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok, i have been trying to make a tiny little text game, its really simple, but when i try to make it, i get an error, tell me wats wrong plz #include <iostream> #include <windows.h> using namespace std; int main(){ cout << "in this game, a random number will be selected, and you must guess it \n"; cout << "generating number" << "\n"; int x; x = rand(); for(;;){ int guess; cout << "try to guess the number: "; cin >> guess; cout << "\n"; if(guess == x){ MessageBox(NULL, "that was correct, good job!!!", "you win", MB_OK | MB_HELP); break; } if(guess < x){ cout << "higher!" << "\n"; } if(guess > x){ cout << "lower!" << "\n"; } } }

Share this post


Link to post
Share on other sites
What is the error? I'm going to guess that it is complaining about WinMain missing. Unless you are building a Windows application, do not include windows.h. That means you can't use MessageBox, but you can use std::cout instead to print to the console.

Share this post


Link to post
Share on other sites
My guess is you get an error like "Cannot convert const char* to LPCWSTR". If that's the case, change your project settings to Multi Byte Character Set instead of Unicode (Project Properties (Alt+F7) -> Configuration Properties -> General -> Character Set, in VC2005 from memory - it's probably the same in VC2003 or VC2008).

Share this post


Link to post
Share on other sites

This topic is 3592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this