I'm Making Nim, the game, and I was wondering where my syntax errors are??
Thanks for all the help!!!
|
It's just syntax I believe
|
can someone at least tell why it says expected primary expression before else? is it something with brackets?
|
The version of gcc I'm using (4.7.1) gives clearer error messages:
Code:
make nim.o Did you write up the whole program and only then try to compile it? It's much easier to build up a program in small steps, ensuring every step is correct. |
I'm not quite sure how to fix my mistakes now
and I didn't write them all separately |
So what ntubski was suggesting was to start from the beginning with a very small program that compiles, e.g.:
Code:
#include <iostream> Then add another chunk of the original programme - and ask the same questions: does it compile? does it do what is expected? Lather, rinse, repeat... Hope this helps, |
Right, I got that, but I how do I fix the compiler errors at hand?
|
...by starting with a small program that works and compiles, and building up. Honestly, that's the only way you're going to learn to write C++ right, if you'll allow me to turn a phrase.
However, almost all of your errors will be solved by putting a '{' after the ')' of an 'if' statement, and a '}' at the end of the block (normally before the 'else'). For example: Code:
... |
so is that what it's supposed to look like?
|
Changed
|
Um... The changes you made are nothing to do with the proper layout of the if statement, as I suggested. Try doing that...
|
It's still not working
|
Please, for the love of Cthulhu, start with something small (like the code I posted in this post) and work up to the whole thing. There are so many syntax errors in your code that you are not going to be able to fix it without a much better knowledge of C++ than you currently have. If you start small, then any errors you have should be far more easily fixable than the code you currently have.
|
I'm sorry, I didn't mean to irritate you, I'm just frustrated at this point and don't have enough patience to break the code up
|
And I'm sorry, I shouldn't have got irritated either. I'm going to put on some laundry, and when I get back I will fix part of your code for you so you can see what we're aiming for...
|
All times are GMT -5. The time now is 06:27 AM. |