[SOLVED] I'm Making Nim, the game, and I was wondering where my syntax errors are??
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
The version of gcc I'm using (4.7.1) gives clearer error messages:
g++ -Wall -Wextra -Wformat=2 -g -ansi -pedantic -std=c++98 -c -o nim.o nim.cc
nim.cc: In function ‘int main()’:
nim.cc:29:13: error: ‘else’ without a previous ‘if’
nim.cc:31:13: error: ‘else’ without a previous ‘if’
nim.cc:36:13: error: ‘else’ without a previous ‘if’
nim.cc:38:13: error: ‘else’ without a previous ‘if’
nim.cc:43:13: error: ‘else’ without a previous ‘if’
nim.cc:45:13: error: ‘else’ without a previous ‘if’
nim.cc:49:13: error: expected ‘)’ before ‘cout’
nim.cc:58:17: error: ‘else’ without a previous ‘if’
nim.cc:65:17: error: ‘else’ without a previous ‘if’
nim.cc:72:17: error: ‘else’ without a previous ‘if’
make: *** [nim.o] Error 1
And indeed your ifs aren't connected to your elses (remember this isn't python, indentation doesn't affect the meaning). Also, you don't have a closing brace for your main() function.
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.
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.