I past all my day to fix Code Blocks, I had a lot of troubles with it. Seems to be fixed, I decide to code and i'm trying to display a tray ( two dimensional arrays ) as a parameter of a function. I follow an answer on this website to make it right. But now, i have an error when I compile. Here's my files.
main.c
#include <stdio.h>
#include <stdlib.h>
#include "SudokuH.h"
int main(void)
{
int tray[9][9]={};
displayTray(numRows, numCols, tray);
return 0;
}
SudokuH.h
#ifndef SUDOKUH_H_INCLUDED
#define SUDOKUH_H_INCLUDED
int numRows = 9;
int numCols = 9;
int i,j;
void displayTray (int numRows, int numCols, int pt[][numCols]);
#endif // SUDOKUH_H_INCLUDED
SudokuS.c
#include <stdio.h>
#include <stdlib.h>
#include "SudokuH.h"
void displayTray(int numRows, int numCols, int pt[][numCols]){
printf("A|B|C|D|E|F|G|H|I\n");
for (i=0; i<numRows;i++){
printf("%d|",i);
for (j=0; j<numCols;j++){
printf("%i|",pt[i][j]);
}
}
}
At the beginning, I thought this error came from CodeBlocks but i try to make again without creating a project and it didn't work. And my others programs seem to work. So what's wrong with my code ? I checked my parameter but it seems ok so maybe it's my way to use a two dimensional array as parameter ? The error is :
||=== Build: Debug in Sudoku (compiler: GNU GCC Compiler) ===| ||error: ld returned 1 exit status| ||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
I have this in the build log :
obj\Debug\main.o:main.c:(.data+0x0): first defined here obj\Debug\SudokuS.o:SudokuS.c:(.data+0x4): multiple definition of `numCols' obj\Debug\main.o:main.c:(.data+0x4): first defined here collect2.exe: error: ld returned 1 exit status