12 errors

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Aug 2008
Posts: 4
Reputation: errorman is an unknown quantity at this point 
Solved Threads: 0
errorman errorman is offline Offline
Newbie Poster

12 errors

 
0
  #1
Aug 22nd, 2008
  1. #include <iostream>
  2.  
  3. using namespace std
  4.  
  5. ;char (name)[20];
  6. int helps;
  7. void (checkOutVillage) (void);
  8.  
  9. int main(void){
  10. {
  11. std==cout << "Please Enter Your Name!" << std==endl;
  12. cin >> name;
  13. std==cout << "You Are On A Great Quest" << name; << std==endl;
  14. std==cout << "There Is A Small Village In Trouble. Should We Help Them?" << std==endl;
  15. std==cout<< "(enter for yes and 2 for no)" << std==endl;
  16. cin >> help;
  17.  
  18. if (help ==1)
  19. {
  20. void(checkOutVillage)();
  21. }
  22. else
  23. {
  24. std==cout << "You Suck!" <<name; << "You Are No Fun At All!!" << std==endl;
  25. getchar();
  26.  
  27. }return 0;
  28. }
  29.  
  30. void (checkOutVillage)(void)
  31. {
  32. int goblinAnswer;
  33.  
  34. std==cout << "well we go check out the village!!" <<std==endl;
  35. std==cout << "There are crazy goblins attacking" <<std==endl;
  36. std==cout << "You should Help!" <<std==end1;
  37. std==cout << "(enter 1 for yes and 2 for no) " <<std==endl;
  38. cin >> goblinAnswer;
  39.  
  40. if (goblinAnswer ==1);
  41. {
  42. std==cout <<"We go kill all the goblins and they die...we win...WE ROCK!!!" << std==endl;
  43. getchar();
  44.  
  45.  
  46. }
  47. else
  48. {
  49. std==cout << "You Suck!!! The Goblins killed everyone and now they are coming for us!!! way to go..." <<std==endl;
  50. getchar();
  51.  
  52. }
  53. }
  54. }
--------------------Configuration: rpg - Win32 Debug--------------------
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)
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: 12 errors

 
0
  #2
Aug 22nd, 2008
Well you need to go back to basics. The following compiles but the logic is probably wrong.

  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. char name[20];
  6. int help;
  7.  
  8. void checkOutVillage ( void );
  9.  
  10. int main ( void )
  11. {
  12.  
  13. cout << "Please Enter Your Name!" << endl;
  14. cin >> name;
  15. cout << "You Are On A Great Quest" << name << endl;
  16. cout << "There Is A Small Village In Trouble. Should We Help Them?" << endl;
  17. cout << "(enter for yes and 2 for no)" << endl;
  18. cin >> help;
  19.  
  20. if ( help == 1 )
  21. {
  22. checkOutVillage();
  23. }
  24. else
  25. {
  26. cout << "You Suck!" << name << "You Are No Fun At All!!" << endl;
  27. getchar();
  28. }
  29. return 0;
  30. }
  31.  
  32. void checkOutVillage ( void )
  33. {
  34. int goblinAnswer;
  35.  
  36. cout << "well we go check out the village!!" << endl;
  37. cout << "There are crazy goblins attacking" << endl;
  38. cout << "You should Help!" << endl;
  39. cout << "(enter 1 for yes and 2 for no) " << endl;
  40. cin >> goblinAnswer;
  41.  
  42. if ( goblinAnswer == 1 )
  43. {
  44. cout << "We go kill all the goblins and they die...we win...WE ROCK!!!" << endl;
  45. getchar();
  46. }
  47. else
  48. {
  49. cout << "You Suck!!! The Goblins killed everyone and now they are coming for us!!! way to go..." << endl;
  50. getchar();
  51. }
  52. }
Last edited by iamthwee; Aug 22nd, 2008 at 1:31 pm.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,814
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: 12 errors

 
0
  #3
Aug 22nd, 2008
Originally Posted by errorman View Post
  1. #include <iostream>
  2.  
  3. using namespace std
  4.  
  5. ;char (name)[20];
  6. int helps;
  7. void (checkOutVillage) (void);
  8.  
  9. int main(void){
  10. {
  11. std==cout << "Please Enter Your Name!" << std==endl;
  12. cin >> name;
  13. std==cout << "You Are On A Great Quest" << name; << std==endl;
  14. std==cout << "There Is A Small Village In Trouble. Should We Help Them?" << std==endl;
  15. std==cout<< "(enter for yes and 2 for no)" << std==endl;
  16. cin >> help;
  17.  
  18. if (help ==1)
  19. {
  20. void(checkOutVillage)();
  21. }
  22. else
  23. {
  24. std==cout << "You Suck!" <<name; << "You Are No Fun At All!!" << std==endl;
  25. getchar();
  26.  
  27. }return 0;
  28. }
  29.  
  30. void (checkOutVillage)(void)
  31. {
  32. int goblinAnswer;
  33.  
  34. std==cout << "well we go check out the village!!" <<std==endl;
  35. std==cout << "There are crazy goblins attacking" <<std==endl;
  36. std==cout << "You should Help!" <<std==end1;
  37. std==cout << "(enter 1 for yes and 2 for no) " <<std==endl;
  38. cin >> goblinAnswer;
  39.  
  40. if (goblinAnswer ==1);
  41. {
  42. std==cout <<"We go kill all the goblins and they die...we win...WE ROCK!!!" << std==endl;
  43. getchar();
  44.  
  45.  
  46. }
  47. else
  48. {
  49. std==cout << "You Suck!!! The Goblins killed everyone and now they are coming for us!!! way to go..." <<std==endl;
  50. getchar();
  51.  
  52. }
  53. }
  54. }
--------------------Configuration: rpg - Win32 Debug--------------------
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:

  1. using namespace std;

you can take out the std:: qualifier since it's already taken care of with:

  1. using namespace std;
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC