문제

#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"

도움이 되었습니까?

해결책

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

void printBoard(void);

void main(...)

다른 팁

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);

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top