confusing parse error

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2008
Posts: 1
Reputation: kalku23 is an unknown quantity at this point 
Solved Threads: 0
kalku23 kalku23 is offline Offline
Newbie Poster

confusing parse error

 
0
  #1
Oct 14th, 2008
I keep getting this error and cant figure it out
thanks for the input.


runcs216p6.cxx: In function `int main()':
runcs216p6.cxx:57: error: parse error before `catch'



  1. int main()
  2. {
  3.  
  4. ifstream inFile;
  5. ofstream outFile;
  6.  
  7. inFile.open("in.data");
  8. outFile.open("out.data");
  9. if(inFile.fail() || outFile.fail())
  10. {
  11. cout << "input or out file opening failed" << endl;
  12. exit(1);
  13. }
  14.  
  15. char n;
  16. int counter;
  17.  
  18. counter = 0;
  19.  
  20. StackType s;
  21. Queue q;
  22.  
  23. inFile >> n;
  24.  
  25. while(inFile)
  26. {
  27. if(s.IsFull())
  28. throw "~~Stack Overflow! No Push!";
  29. if(q.IsFull())
  30. throw "~~Queue Overflow! No Enqueue!";
  31. else{
  32. s.Push(n);
  33. q.Enqueue(n);
  34. outFile << n;
  35. counter++;}
  36.  
  37. inFile >> n;
  38. }
  39. catch(std::char * s)
  40. {
  41. outFile<<s;
  42. }
  43. return 0;
  44. }
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,502
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1479
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: confusing parse error

 
0
  #2
Oct 14th, 2008
>>catch(std::char * s)

Error most likely because there is no such thing as std::char. change to this and retest: catch(const char* s)
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC