Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Game Of Life
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
a22asin




PostPosted: Fri Sep 26, 2014 8:05 am   Post subject: Game Of Life

Hi, so im trying to implement Conway's Game of Life. I have an idea of how im going to do it. My problem is that within 10 min of coding, i get these errors:
code:

GameOfLife.cpp:10: error: multidimensional array must have bounds for all dimensions except the first
GameOfLife.cpp:10: error: expected ?,? or ?...? before ?loc?
GameOfLife.cpp:12: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x
GameOfLife.cpp:14: error: expected primary-expression before ?int?
GameOfLife.cpp:14: error: expected ?}? before ?int?
GameOfLife.cpp:14: error: expected ?,? or ?;? before ?int?
GameOfLife.cpp:18: error: expected constructor, destructor, or type conversion before ?<<? token
GameOfLife.cpp:19: error: expected constructor, destructor, or type conversion before ?>>? token
GameOfLife.cpp:20: error: expected constructor, destructor, or type conversion before ?<<? token
GameOfLife.cpp:21: error: expected constructor, destructor, or type conversion before ?>>? token
GameOfLife.cpp:23: error: expected unqualified-id before ?for?
GameOfLife.cpp:23: error: expected constructor, destructor, or type conversion before ?>? token
GameOfLife.cpp:27: error: expected declaration before ?}? token


I cannot, for the life of me, figure out why im getting these errors. I have tried to research how to use my codes and what not and i followed it to the dot. Can someone please help me out here and point me to the right direction?

code:

#include <iostream>
#include <cstdlib>

using namespace std;

const int MAX_X = 1000;
const int MAX_Y = 1000;
const int MAX_CELL = 100;

int death(int[][] loc, Strig[] c, int s);

int main{
       
        int occupied;
        int steps;
        int loc [MAX_CELL][MAX_CELL];

        cout << "How many occupied cells would you like to make: ";
        cin >> occupied;
        cout << "How many steps should be preformed: ";
        cin >> steps;

        for (int i = 0; i > steps; i++){
       

        }
}

int death(int[][] loc, String[] c,int s){

        for (int i = 0; i > o; i++){
                for (int j = 0; j > o; j++){
               
                }
        }
}
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Fri Sep 26, 2014 1:05 pm   Post subject: Re: Game Of Life

Start from the first error:
a22asin @ Fri Sep 26, 2014 8:05 am wrote:
[line]10: error: multidimensional array must have bounds for all dimensions except the first

what the message is saying is that you want
code:

int[][100]

not
code:

int[][]
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
a22asin




PostPosted: Fri Sep 26, 2014 1:19 pm   Post subject: Re: Game Of Life

ok, then what about the remainder of the errors:

code:

GameOfLife.cpp:10: error: expected ?,? or ?...? before ?loc?
GameOfLife.cpp:12: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x
GameOfLife.cpp:14: error: expected primary-expression before ?int?
GameOfLife.cpp:14: error: expected ?}? before ?int?
GameOfLife.cpp:14: error: expected ?,? or ?;? before ?int?
GameOfLife.cpp:18: error: expected constructor, destructor, or type conversion before ?<<? token
GameOfLife.cpp:19: error: expected constructor, destructor, or type conversion before ?>>? token
GameOfLife.cpp:20: error: expected constructor, destructor, or type conversion before ?<<? token
GameOfLife.cpp:21: error: expected constructor, destructor, or type conversion before ?>>? token
GameOfLife.cpp:23: error: expected unqualified-id before ?for?
GameOfLife.cpp:23: error: expected constructor, destructor, or type conversion before ?>? token
GameOfLife.cpp:23: error: expected constructor, destructor, or type conversion before ?++? token
GameOfLife.cpp:27: error: expected declaration before ?}? token


ive tried going through the error and figuring it out. Like for line 12, i do say using namespace std at the beginning, so i dont know why that comes up, i have all the necessary brackets and other punctuations in my code (as you can see above), but im still getting the error.
Tony




PostPosted: Fri Sep 26, 2014 1:36 pm   Post subject: RE:Game Of Life

G++ was giving me a different set of errors, which lead to looking up the documentation to what's expected -- http://www.cplusplus.com/doc/tutorial/arrays/
code:

int loc[][100]
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
a22asin




PostPosted: Fri Sep 26, 2014 1:46 pm   Post subject: RE:Game Of Life

ok, so after the painstaking hours of searching fro my problems, i have finally got my program working. Thanks Tony. The only problem now is that my g++ keeps giving me the error that the directory or file doesn't exist; im working on a linux shell (which im using for another class as well).
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: