Ok so i'm now writing a program which has a 5 x 5 grid. The starting point is at [0,0] and the finish point is somewhere on the grid. The point of the program is to find the finish point and plot route from 0,0 to the finish point
here is the code
keeps giving me this compile errorCode:#include<stdio.h> #include<string.h> #define SQ_GRID 5 int Grid[SQ_GRID][SQ_GRID]; int finishYCord = 0; int finishXCord = 0; int startYCord = 0; int startXCord = 0; //takes starting point and plants it on the grid. void plotRoute(){ if(startYCord > finishYCord){ while(startYCord > finishYCord){ moveDown(); } } else{ while(startYCord < finishYCord){ moveUp(); } } } void moveDown(){ startYCord--; printf("[%d, %d] ", startYCord,startXCord); } moveUp(){ startYCord++; printf("[%d, %d] ", startYCord,startXCord); } void startingPoint(int yaxis, int xaxis) { Grid[yaxis][xaxis] = 1; } void finishingPoint(int fYAxis, int fXAxis) { Grid [fYAxis][fXAxis] = 2; printf("GRID [%d][%d] Contains %d\n",fYAxis,fXAxis,Grid[fYAxis][fXAxis]); } void printGrid(){ int k; int l; for(k=0;k<SQ_GRID;k++){ for(l=0;l<SQ_GRID;l++){ printf("GRID[%d][%d]now contains %d\n",k,l,Grid[k][l]); } } } void fillArr(){ int k; int l; for(k=0;k<SQ_GRID;k++){ for(l=0;l<SQ_GRID;l++){ Grid[k][l] == 0; printf("GRID[%d][%d]now contains %d\n",k,l,Grid[k][l]); } } } void findFinish(){ int i; int fFlagFound = 0; int j; for(i = 0; i < SQ_GRID; i++){ for(j = 0; j < SQ_GRID; j++){ if(Grid[i][j] == 2){ finishYCord = i; finishXCord = j; printf("\n\nFound finish in Grid [%d][%d]\n",finishYCord,finishXCord); fFlagFound++; } } } if(fFlagFound == 0){ printf("Flag Not Found!\n"); } } int main(){ startYCord= 0; startXCord =0; fillArr(); finishingPoint(4,3); printGrid(); findFinish(); plotRoute(); return 0; }
grid.c:32: error:conflicting types for moveDown
grid.c:19: error: Previous implicit declaration of moveDown was here
I had it running before but the code didnt work properly. After i changed it i get this.