Structs(Sample Code):

  1. ifndef MAZE_H
  2. define MAZE_H
  3. include <stdio.h>

typedef struct { int startRow,startCol; int exitRow, exitCol; int numRow,numCol;

int** cells; }Maze;

Maze Maze_construct(char* frame); void Maze_traverse(Maze m); void Maze_destruct(Maze m);

  1. endif


In "maze.c":


/*maze.c*/

  1. include "maze.h"
  2. include <stdio.h>

Maze Maze_contruct(char* fname) { FIEL* fMaze; fMaze = fopen(fname); if(fMaze ==0) { //error } while(!feof(fMaze)) { //stuff } }


  1. include <stdio.h> main.c
  2. include "maze.h"

int main() { Maze m; if(argc<2) { //error } m = Mazeconstruct(argv[1]); Maze_traverse(m) Maze_destruct(m) return 0; }

gcc -c maze.c need malloc gcc maze.o main.o -o implicitly link c library

m.cells = malloc (sizeof(char*) * numRow); for

How to define the Struct:

typedef struct { int x; int y; int z; }Vector;

Vector Vector_construct(int a int b int c); Vector Vector_add(vector v1 vector v2);

Vector Vector_construct(int a, int b, int c) Pbecor v;

Commands needed in Makefile or just in terminal to properly compile.

gcc -c main.c gcc -c maze.c gcc main.o maze.o -o ipa1 ./ipa1 maze1 <-- means the current folder's ipa1 file. current directory make file for each directory makeclean

Alumni Liaison

has a message for current ECE438 students.

Sean Hu, ECE PhD 2009