| | |
12 errors
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Aug 2008
Posts: 4
Reputation:
Solved Threads: 0
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std ;char (name)[20]; int helps; void (checkOutVillage) (void); int main(void){ { std==cout << "Please Enter Your Name!" << std==endl; cin >> name; std==cout << "You Are On A Great Quest" << name; << std==endl; std==cout << "There Is A Small Village In Trouble. Should We Help Them?" << std==endl; std==cout<< "(enter for yes and 2 for no)" << std==endl; cin >> help; if (help ==1) { void(checkOutVillage)(); } else { std==cout << "You Suck!" <<name; << "You Are No Fun At All!!" << std==endl; getchar(); }return 0; } void (checkOutVillage)(void) { int goblinAnswer; std==cout << "well we go check out the village!!" <<std==endl; std==cout << "There are crazy goblins attacking" <<std==endl; std==cout << "You should Help!" <<std==end1; std==cout << "(enter 1 for yes and 2 for no) " <<std==endl; cin >> goblinAnswer; if (goblinAnswer ==1); { std==cout <<"We go kill all the goblins and they die...we win...WE ROCK!!!" << std==endl; getchar(); } else { std==cout << "You Suck!!! The Goblins killed everyone and now they are coming for us!!! way to go..." <<std==endl; getchar(); } } }
Compiling...
rpg.cpp
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(11) : error C2882: 'std' : illegal use of namespace identifier in expression
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(11) : error C2882: 'std' : illegal use of namespace identifier in expression
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(13) : error C2882: 'std' : illegal use of namespace identifier in expression
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(13) : error C2143: syntax error : missing ';' before '<<'
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(14) : error C2882: 'std' : illegal use of namespace identifier in expression
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(14) : error C2882: 'std' : illegal use of namespace identifier in expression
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(15) : error C2882: 'std' : illegal use of namespace identifier in expression
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(15) : error C2882: 'std' : illegal use of namespace identifier in expression
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(16) : error C2065: 'help' : undeclared identifier
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(24) : error C2882: 'std' : illegal use of namespace identifier in expression
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(24) : error C2143: syntax error : missing ';' before '<<'
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(30) : error C2601: 'checkOutVillage' : local function definitions are illegal
Error executing cl.exe.
rpg.obj - 12 error(s), 0 warning(s)
Well you need to go back to basics. The following compiles but the logic is probably wrong.
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; char name[20]; int help; void checkOutVillage ( void ); int main ( void ) { cout << "Please Enter Your Name!" << endl; cin >> name; cout << "You Are On A Great Quest" << name << endl; cout << "There Is A Small Village In Trouble. Should We Help Them?" << endl; cout << "(enter for yes and 2 for no)" << endl; cin >> help; if ( help == 1 ) { checkOutVillage(); } else { cout << "You Suck!" << name << "You Are No Fun At All!!" << endl; getchar(); } return 0; } void checkOutVillage ( void ) { int goblinAnswer; cout << "well we go check out the village!!" << endl; cout << "There are crazy goblins attacking" << endl; cout << "You should Help!" << endl; cout << "(enter 1 for yes and 2 for no) " << endl; cin >> goblinAnswer; if ( goblinAnswer == 1 ) { cout << "We go kill all the goblins and they die...we win...WE ROCK!!!" << endl; getchar(); } else { cout << "You Suck!!! The Goblins killed everyone and now they are coming for us!!! way to go..." << endl; getchar(); } }
Last edited by iamthwee; Aug 22nd, 2008 at 1:31 pm.
*Voted best profile in the world*
•
•
Join Date: Jan 2008
Posts: 3,814
Reputation:
Solved Threads: 501
•
•
•
•
--------------------Configuration: rpg - Win32 Debug--------------------C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std ;char (name)[20]; int helps; void (checkOutVillage) (void); int main(void){ { std==cout << "Please Enter Your Name!" << std==endl; cin >> name; std==cout << "You Are On A Great Quest" << name; << std==endl; std==cout << "There Is A Small Village In Trouble. Should We Help Them?" << std==endl; std==cout<< "(enter for yes and 2 for no)" << std==endl; cin >> help; if (help ==1) { void(checkOutVillage)(); } else { std==cout << "You Suck!" <<name; << "You Are No Fun At All!!" << std==endl; getchar(); }return 0; } void (checkOutVillage)(void) { int goblinAnswer; std==cout << "well we go check out the village!!" <<std==endl; std==cout << "There are crazy goblins attacking" <<std==endl; std==cout << "You should Help!" <<std==end1; std==cout << "(enter 1 for yes and 2 for no) " <<std==endl; cin >> goblinAnswer; if (goblinAnswer ==1); { std==cout <<"We go kill all the goblins and they die...we win...WE ROCK!!!" << std==endl; getchar(); } else { std==cout << "You Suck!!! The Goblins killed everyone and now they are coming for us!!! way to go..." <<std==endl; getchar(); } } }
Compiling...
rpg.cpp
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(11) : error C2882: 'std' : illegal use of namespace identifier in expression
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(11) : error C2882: 'std' : illegal use of namespace identifier in expression
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(13) : error C2882: 'std' : illegal use of namespace identifier in expression
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(13) : error C2143: syntax error : missing ';' before '<<'
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(14) : error C2882: 'std' : illegal use of namespace identifier in expression
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(14) : error C2882: 'std' : illegal use of namespace identifier in expression
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(15) : error C2882: 'std' : illegal use of namespace identifier in expression
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(15) : error C2882: 'std' : illegal use of namespace identifier in expression
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(16) : error C2065: 'help' : undeclared identifier
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(24) : error C2882: 'std' : illegal use of namespace identifier in expression
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(24) : error C2143: syntax error : missing ';' before '<<'
C:\Users\PepperEtSpock\Desktop\rpg\rpg.cpp(30) : error C2601: 'checkOutVillage' : local function definitions are illegal
Error executing cl.exe.
rpg.obj - 12 error(s), 0 warning(s)
You are perhaps confusing
std==cout with std::cout . std::cout means "use cout from the standard namespace". std==cout means nothing. You want two colons, not two equals signs to refer to namespaces. However, since you are using this line at the top: C++ Syntax (Toggle Plain Text)
using namespace std;
you can take out the
std:: qualifier since it's already taken care of with: C++ Syntax (Toggle Plain Text)
using namespace std;
![]() |
Similar Threads
- Simple Programming Errors (Computer Science)
- confused with errors in c++ (C++)
- Windows XP and Corel Suite 8 (WP8) errors (Windows NT / 2000 / XP)
- Loader.EXE and IEDLL.EXE errors (Web Browsers)
- Errors during scandisk (Windows 95 / 98 / Me)
- Upgrading Xp Home to Pro - ERRORS! (Windows NT / 2000 / XP)
- strange annoying errors (Windows NT / 2000 / XP)
- w2k server errors (Windows NT / 2000 / XP)
- Two Problems- "Page Cannot Be Displayed" Errors, Z (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: Help with creating a class
- Next Thread: C++ Classes
| Thread Tools | Search this Thread |
api array arrays based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






