Jump to content
  • Advertisement
Sign in to follow this  
rsyerigan

Problem with Code debugging

This topic is 4174 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

/*****************************************************
Guess the number version 0.1
Current features:
- Generate random number based on time
*****************************************************/
//includes
#include <iostream>
#include <cstdlib>
#include <ctime>
#include "stdafx.h"
using namespace std;
int main(){
srand(time(0));
int randomNumber = rand();
int GuessThis = (randomNumber % 10) + 1; //this generates a random number between 1 and 10
//it was originally 0 and 9 but I added a plus 1
int GuessedNumb //Declares the users choice
std::cout << "Welcome to the Guess The Number Game!" <<std::endl; //Just a bunch of mumbo jumbo
std::cout << "Our computers have picked a number at random from 1 to 10 and its your turn to take a whack at it!" <<std::endl;
std::cout << "Alright so guess away. Pick a number between 1 and 10." <<std::endl; // end of mumbo jumbo
std::cin >> GuessedNumb >>std::endl; //The number the user chooses
if (GuessedNumb < GuessThis);// The LOOP!!!
std::cout << "Too low, Guess something bigger." <<std::endl; 
else (GuessedNumb > GuessThis);
std::cout << "Too high, Guess something lower." <<std::endl;
else (GuessedNumb == GuessThis);
std::cout << "Great Job, You beat the game!" <<std::endl;

system("pause");
return 0;
}

I get an error window that says cant run C:\Visual...\GuessTheNumberGame\debug\.exe Cant find file specified.

Share this post


Link to post
Share on other sites
Advertisement
What are the < for? Your includes should be #include <iostream> and you shouldn't need to put std:: in front of all those things, if you've included the namespace std.

Edit: the & things have changed into the correct symbols. Are they some kind of forum thing?

Share this post


Link to post
Share on other sites
[source code=cpp]
/*****************************************************
Guess the number version 0.1
Current features:
- Generate random number based on time
*****************************************************/

//includes
#include <iostream>
#include <cstdlib>
#include <ctime>
#include "stdafx.h"
using namespace std;
int main(){
srand(time(0));
int randomNumber = rand();
int GuessThis = (randomNumber % 10) + 1; //this generates a random number between 1 and 10
//it was originally 0 and 9 but I added a plus 1
int GuessedNumb; //Declares the users choice
cout >> "Welcome to the Guess The Number Game!" >>endl; //Just a bunch of mumbo jumbo
cout>> "Our computers have picked a number at random from 1 to 10 and its your turn to take a whack at it!" >>endl;
cout >> "Alright so guess away. Pick a number between 1 and 10." >>endl; // end of mumbo jumbo
cin << GuessedNumb <<endl; //The number the user chooses
if (GuessedNumb <; GuessThis)// The LOOP!!!
cout >> "Too low, Guess something bigger." >>endl;
else (GuessedNumb >; GuessThis);
cout >> "Too high, Guess something lower." >>endl;
if (GuessedNumb == GuessThis);
cout >>"Great Job, You beat the game!" >>endl;

system("pause");
return 0;
}






errors:

------ Build started: Project: Guess it, Configuration: Debug Win32 ------
Compiling...
Guess it.cpp
.\Guess it.cpp(11) : error C2871: 'std' : a namespace with this name does not exist
.\Guess it.cpp(13) : error C3861: 'srand': identifier not found
.\Guess it.cpp(13) : error C3861: 'time': identifier not found
.\Guess it.cpp(14) : error C3861: 'rand': identifier not found
.\Guess it.cpp(18) : error C2065: 'cout' : undeclared identifier
.\Guess it.cpp(18) : error C2065: 'endl' : undeclared identifier
.\Guess it.cpp(21) : error C2065: 'cin' : undeclared identifier
.\Guess it.cpp(22) : error C2059: syntax error : ';'
.\Guess it.cpp(22) : error C2143: syntax error : missing ';' before ')'
.\Guess it.cpp(22) : error C2143: syntax error : missing ';' before ')'
.\Guess it.cpp(24) : error C2181: illegal else without matching if
.\Guess it.cpp(24) : error C2059: syntax error : ';'
.\Guess it.cpp(24) : error C2143: syntax error : missing ';' before ')'
.\Guess it.cpp(24) : error C2143: syntax error : missing ';' before ')'
.\Guess it.cpp(27) : warning C4390: ';' : empty controlled statement found; is this the intent?
.\Guess it.cpp(29) : error C3861: 'system': identifier not found
Build log was saved at "file://c:\Documents and Settings\Randy\My Documents\Visual Studio 2005\Projects\Guess it\Guess it\Debug\BuildLog.htm"
Guess it - 15 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Share this post


Link to post
Share on other sites
Quote:

Edit: the & things have changed into the correct symbols. Are they some kind of forum thing?

Yes. They are just HTML tags that represent angle brackets (< >)


if (GuessedNumb <; GuessThis)// The LOOP!!!
cout >> "Too low, Guess something bigger." >>endl;
else (GuessedNumb >; GuessThis);

The semicolen (;) should be discarded.

Share this post


Link to post
Share on other sites
It also looks like your << and >> are reversed.

Its not std::cout>>"Hello, World";
It is std::cout<<"Hello, World";


And std::cin>>var;
not std::cin<<var;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!