![]() |
|
#1
|
|||
|
|||
Illegal else without matching ifCPP / C++ / C Code:
^^ my code. Code:
Last edited by admin : 30-Sep-2005 at 23:48.
Reason: Please insert your C code between [c] & [/c] tags
|
|
#2
|
|||
|
|||
Re: I'm very screwed, but please help.First of all, put your code in the right tags.
Secondly, don't put semicolons after the end parenthesis for your if/else stuff. Third, you have an extra bracket after your "Mega Team > Ultra Team > Super Team" thing. Also, for those cout<< ""<<endl; things, you can just use a "\n" if you want a newline, if that's what you're trying to do. |
|
#3
|
|||
|
|||
Re: I'm very screwed, but please help.Quote:
Well, I guess you missed the deadline --- sorry. However, some others reading this thread might wonder what the problem is, so I'll take a shot. There seems to be a lot of: "illegal else without matching if". What could that mean? Could the compiler be more clear in its description of the problem? There are basically two ways to use an if(): Here is one way CPP / C++ / C Code:
Here is another CPP / C++ / C Code:
Note that, if the stuff to be executed consists of a single statement, the braces are optional. And that's it! When the closing bracket at the end of the else block, then that's all you can do with that if. You can't just put an else anywhere you want it to be; it's always associated with an if. So in summary: you can have an if without an else, but you aren't allowed to have an else without an if. Now for the stuff your program wants to do, you can have another if nested within the else: CPP / C++ / C Code:
You can continue nesting to as many levels as you want. This kind of stuff is used so much, that lots of people use the following shorter method of writing, but note that it is exactly the same as the above. This kind of looks like it could be a model for fixing your chain of logic: CPP / C++ / C Code:
Regards, Dave |
|
#4
|
|||
|
|||
Re: Illegal else without matching ifI didn't exactly miss the deadline, but the coding that i handed in (seen above) will receive 50% tops. but thank you very much, you made me realize that I was just typing the code in the wrong way. I've done work in VB so this is completely new to me. I'll be posting some things in the near future, and if I get good enough, even helping people? haha.
|
Recent GIDBlog
Toyota - 2008 September Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| '%' illegal, left operand, has type 'double' | quasimof | C++ Forum | 10 | 27-Jul-2006 14:39 |
| C++ PhoneBook | marita | C++ Forum | 46 | 12-Jun-2005 12:10 |
| "No matching function" error | crystalattice | C++ Forum | 3 | 03-Dec-2004 09:57 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The