0
votes

The error I got:

[Warning] passing arg 1 of `(my function)' from incompatible pointer type

I tried to get my function to read 3 things. I already declared my void function. I already created char* board, char* vehicle, char* distance in my function.

it is in int main()

moveCar(&board, &vehicle, &distance);

it doesn't run my program correctly. What can I do to make it to work smooth?

Updated:

since some of you guys want to take a look at my function. here it is.

void moveCar(char* board[], char* vehicle, char* direction)
{
     int i;
     for (i = 0; i < size; i++)
     {
         if(board[i] = vehicle)
         {
                     if(*direction = 'r')
                     {
                          if(*board[i + 1] = '.')
                          {
                                swap(board, (&i), (&i + 1));
                          }
                     }
                     else if (*direction = 'l')
                     {
                          if(*board[i - 1] = '.')
                          {
                                swap(board, (&i), (&i - 1));
                          }
                     }
                     else if (*direction = 'd')
                     {
                          if(*board[i + 8] = '.')
                          {
                                swap(board, (&i), (&i + 8));
                          }
                     }
                     else if(*direction = 'u')
                     {
                          if(*board[i - 8] = '.')
                          {
                                swap(board, (&i), (&i - 8));
                          }
                     }
         }
     }
}
1
we should at least see the function declaration and the arguments declaration - Jack
show more code: ideally, both your function definition and the place from where it's called. - Ashalynd
Unless my_function is actually a function pointer (and I'm guessing it isn't), it should not be in brackets. - abligh
Are you sure you want to pass the address of board etc.? If they're strings, you leave off the & - EOF
Please update your question to include the definition of my function (whatever it is). - Lee Duhem

1 Answers

0
votes

According to the definitions of your function and variables

char* board;
char* vehicle;
char* distance;

void moveCar(char* board[], char* vehicle, char* direction) { ... }

You should call moveCar() as

moveCar(&board, vehicle, distance);