Question

#include <stdio.h>
#define MAX 9

void main (int argc, char *argv[]) {

  printBoard();

}

void printBoard(void) {
  int row,col;
  row=col=0;

  for(row;row<MAX;row++)   //row navigation
    for(col;col<MAX;col++){//column navigation
      printf("r:%d,c:%d",row,col);
    }/*End Column Nav*/

  printf("\n");
}

I'm not sure what I am doing wrong here - the error I get :

"warning: conflicting types for ‘printBoard’ [enabled by default] note: previous implicit declaration of ‘printBoard’ was here"

Était-ce utile?

La solution

Try adding a function prototype for printBoard above main() e.g.,

void printBoard(void);

void main(...)

Autres conseils

You have declared function after calling it.

#include <stdio.h>
#define MAX 9

void printBoard(void) {
  int row,col;
  row=col=0;

  for(row;row<MAX;row++)   //row navigation
    for(col;col<MAX;col++){//column navigation
      printf("r:%d,c:%d",row,col);
    }/*End Column Nav*/

  printf("\n");
}
void main (int argc, char *argv[]) {

  printBoard();

}

This should work pretty fine.

Edit: You should declar all function before calling any of them.
Like void printBoard(void);

You are calling the method before it is declared.

Solve the problem by:

1) Moving the definition of void printBoard(void) above main or

2) adding a declaration above main. Just this line: void printBoard(void);

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top