The Artima Developer Community
Sponsored Link

C# Answers Forum
parsing problem in C++ ( I'm still learning )

2 replies on 1 page. Most recent reply: Jun 19, 2003 11:41 PM by Phil

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Phil

Posts: 2
Nickname: agentzero
Registered: Jun, 2003

parsing problem in C++ ( I'm still learning ) Posted: Jun 17, 2003 6:54 AM
Reply to this message Reply
Advertisement
having looked through numerous websites and tried their examples on exception handling I keep getting the same message ( I'm still learning C++ java I'm ok with ) I get an error message up every time without fail saying "parse error before "}" . any clues ?


Exception handling has been enabled.


#include <iostream.h>

int main () {
char myarray[10];
try
{
for (int n=0; n<=10; n++)
{
if (n>9) throw "Out of range";
myarray[n]='z';
}
}
catch (char * str)
{
cout << "Exception: " << str << endl;
}
return 0;
}
}

is this a known problems or am I doing something wrong ( should be the above example was taken from http://www.cplusplus.com/doc/tutorial/tut5-3.html )


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: parsing problem in C++ ( I'm still learning ) Posted: Jun 17, 2003 2:30 PM
Reply to this message Reply
This doesn't have anything to do with C#, but it looks like you have too many closing braces.

int main () 
{
   char myarray[10];
   try
   {
      for (int n=0; n<=10; n++)
      {
         if(n>9)
            throw "Out of range";
         myarray[n]='z';
      }
   }
   catch (char * str)
   {
      cout << "Exception: " << str << endl;
   }
   return 0;
 
   } <<--- What's this???
 
}

Phil

Posts: 2
Nickname: agentzero
Registered: Jun, 2003

Re: parsing problem in C++ ( I'm still learning ) Posted: Jun 19, 2003 11:41 PM
Reply to this message Reply
Yep you're absolutely right and point taken.

Flat View: This topic has 2 replies on 1 page
Topic: Assembly reference Previous Topic   Next Topic Topic: Write a method header

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use