Problem with Code debugging

Started by
11 comments, last by Crypter 16 years, 12 months ago

/*****************************************************
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.
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?
guess so
[source code=cpp]/*****************************************************Guess the number version 0.1Current 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 1int GuessedNumb; //Declares the users choicecout >> "Welcome to the Guess The Number Game!" >>endl; //Just a bunch of mumbo jumbocout>> "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 jumbocin << GuessedNumb <<endl; //The number the user choosesif (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 ==========
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.
not sure what it is at the moment, but it looks like you forgot an include.
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;

[size=1]Visit my website, rawrrawr.com

This may seem obvious, but are you sure that the paths for the include file directories are correct?
Strength without justice is no vice; justice without strength is no virtue.
wait so the includes arnt right?
Your #includes are correct, but your compiliers INCLUDE\ path varable may
not be correctly set.

This topic is closed to new replies.

Advertisement