tFirst commit - game-of-life - Conway's Game of Life
 (HTM) git clone git://src.adamsgaard.dk/game-of-life
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit a7f420eb10d5e51045b48bda1bc749916ddc21e4
 (HTM) Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
       Date:   Fri,  7 Mar 2014 12:16:16 +0100
       
       First commit
       
       Diffstat:
         A Makefile                            |      14 ++++++++++++++
         A main.c                              |      53 ++++++++++++++++++++++++++++++
       
       2 files changed, 67 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/Makefile b/Makefile
       t@@ -0,0 +1,14 @@
       +CFLAGS=-Wall -pedantic -g -O2
       +#LDLIBS=-lm
       +
       +BIN=gol
       +
       +$(BIN): main.o 
       +        $(CC) $(CFLAGS) $(LDLIBS) $^ -o $@
       +
       +#main.o: file_io.h utility.h boundary.h solution.h
       +#file_io.o: utility.h
       +
       +clean:
       +        $(RM) *.o
       +        $(RM) $(BIN)
 (DIR) diff --git a/main.c b/main.c
       t@@ -0,0 +1,53 @@
       +#include <stdio.h>
       +#include <unistd.h>
       +#include <stdlib.h>
       +#include <ctype.h>
       +
       +#define VERSION 0.1
       +
       +int main(int argc, char **argv)
       +{
       +    int **cells;
       +    int nx = 10;
       +    int ny = 10;
       +    int c;
       +
       +    while ((c = getopt(argc, argv, "hv")) != -1)
       +        switch (c)
       +    {
       +        case 'h':
       +            printf("usage: %s [OPTIONS] nx ny\n"
       +                    "where nx and ny are the grid dimensions.\n"
       +                    "-h\tDisplay help\n"
       +                    "-v\tDisplay version information\n", argv[0]);
       +            return 0;
       +            break;
       +        case 'v':
       +            printf("%s: Conway's Game of Life,"
       +                    "version %.1f\n"
       +                    "Written by Anders Damsgaard, "
       +                    "https://github.com/anders-dc/game-of-life\n", argv[0], VERSION);
       +            return 0;
       +            break;
       +        case '?':
       +            if (isprint(optopt))
       +                fprintf(stderr, "Unknown option `-%c`.\n", optopt);
       +            else
       +                fprintf(stderr, "Unknown option character `\\x%x`.\n", optopt);
       +            return 1;
       +
       +        default:
       +            abort();
       +    }
       +
       +    if (optind == argc - 2) {
       +        nx = atoi(argv[optind]);
       +        ny = atoi(argv[optind + 1]);
       +    } 
       +
       +    printf("Grid dimensions: %dx%d\n", nx, ny);
       +
       +
       +
       +    return 0;
       +}