-3

Language: C

Hello, i am having an error in this line:

start_board(char Board[10][10],char simbol);

Function start_board:

void start_board(char Board[10][10],char simbol)
{
    char BoardJ1[9][COL_MAX];
    char BoardJ2[9][COL_MAX];

    create_board(BoardJ1);
    create_board(BoardJ2);


    for (int i=0; i < 9; i++)
    {
      printf("%s%.8s%s\n", BoardJ1[i], SPACES, BoardJ2[i]);
    }

}

Ideas ?

  • The code shown doesn't use the arguments at all. It is also puzzling that you have `[10][10]` in the argument list and `[9][COL_MAX]` in the local variables. There's going to be unhappiness sooner or later if you are not very careful. – Jonathan Leffler Dec 13 '13 at 15:50

2 Answers2

2

Your function prototype is missing return type void.

In absence of any type, it will implicitly converted to int type. So your function return type is int type which doesn't match with the return type of the function definition.

haccks
  • 104,019
  • 25
  • 176
  • 264
  • >_< hahaha damn! woah lol, sry for wasting your time =P stupid me >=[ – user3099947 Dec 13 '13 at 15:48
  • 2
    You first say 'must have a type of storage class' and then discuss implicit `int`. If the code allows implicit `int`, it is C89/C90 or earlier, and the type or storage class is not necessary. If the type or storage classs is necessary (C99 or later), the code should not use implicit `int`. Having said that, compilers are often lax about these rules for reasons of backwards compatibility. (It is getting to be irritating that GCC still warns about using C99 constructs without explicitly enabling C99 mode.) – Jonathan Leffler Dec 13 '13 at 15:49
  • @JonathanLeffler [This answer](http://stackoverflow.com/a/2193730/28169) suggests invoking the compiler as `c99` instead. I haven't tried that. :) – unwind Dec 13 '13 at 15:51
  • @JonathanLeffler; I added that line because of the compiler warning I got. But soon I realize that what you have said. Removed that line. – haccks Dec 13 '13 at 15:52
1

Besides to the return type that is not mentioned in the declaration, you have another mistake. If you pass the 2D array like that the size would be unknown. You should pass the 2D array and the size of it as below.

void start_board(char Board[][10], size_t size, char symbol);
haccks
  • 104,019
  • 25
  • 176
  • 264
Melika Barzegaran
  • 429
  • 2
  • 9
  • 25
  • You can pass 2D array like that but the problem is unknown length of row (as you mentioned in your answer). The compiler ignores the first dimension. – haccks Dec 13 '13 at 15:57
  • A parameter declared with an array type is really a pointer. Recommended reading: Section 6 of the [comp.lang.c FAQ](http://www.c-faq.com). – Keith Thompson Dec 13 '13 at 16:50