OK, perhaps I should make myself clearer.
My header file looks like the following:
Code:
#ifdef _PUZZLE_H
#define _PUZZLE_H
#include <stdio.h>
#include <stdlib.h>
#define COLS 3
#define ROWS 2
void movePuzzle(int puzzle[][COLS], char dir, int rowcol);
void initPuzzle(int puzzle[][COLS]);
void initPuzzle(int puzzle[][COLS])
{
/* Initialise the puzzle and shuffle it around */
int x, y;
unsigned int seed;
char temp;
/* set up random number generator */
printf("Please enter puzzle seed number : ");
x = scanf("%u", &seed);
if (x != 1)
{
printf("invalid input for seed\n");
exit(0);
}
srand(seed);
/* clear keyboard of newline */
do (scanf("%c", &temp)); while (temp != '\n');
/* fill puzzle */
for (y=0; y<ROWS; y++)
{
for (x=0; x<COLS; x++)
{
puzzle[y][x] = 1 + y * COLS + x;
}
}
/* shuffle puzzle */
for (y=0; y<=ROWS*COLS; y++)
{
if ((rand() % 2) == 0)
{
movePuzzle(puzzle, 'v', rand() % COLS);
}
else
{
movePuzzle(puzzle, 'h', rand() % ROWS);
}
}
}
#endif
No I am trying to call the initPuzzle function from this header file to my source file by doing the following on my .c file:
Code:
#include "puzzle.h"
int main()
{
initPuzzle(int puzzle[][COLS]);
return 0;
}
It gives me a list of several errors, however. Anyone know what I am doing wrong and how I can make these functions work?
Thanks