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

Filburt
  • 17,626
  • 12
  • 64
  • 115
user1695505
  • 265
  • 2
  • 13
  • 1
    At the time of calling, here is no prototype in scope for PrintBoard() Also: main() returns int (there is a(n invisible) prototype in scope) – wildplasser Mar 06 '14 at 00:12
  • 1
    Definite duplicate of [Getting "conflicting types for function" in C, why?](http://stackoverflow.com/questions/1549631/getting-conflicting-types-for-function-in-c-why) – WhozCraig Mar 06 '14 at 00:14
  • The unanswered question is: why does you compiler accept `void main()` ? It is terribly wrong for the same reason. – wildplasser Mar 06 '14 at 00:23

3 Answers3

3

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

void printBoard(void);

void main(...)
ben lemasurier
  • 2,582
  • 4
  • 22
  • 37
2

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

1

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

SomeWittyUsername
  • 18,025
  • 3
  • 42
  • 85
Morten Jensen
  • 5,818
  • 3
  • 43
  • 55