Reputation: 35
I am trying to send this array to the function sortByLength
.
The function prototype is
sortByLength(char *words[],int * lengths, const int size);
Here is the rest of my code up to where I try to pass it to the function:
#include <stdio.h>
#include "task2.h"
#define SIZE 3
int main(void)
{
int i;
int lengths[SIZE] = {3, 4, 6};
char words[][20] = {"Sun", "Rain", "Cloudy"};
sortByLength(words[][20],lengths,SIZE);
return 0;
}
Upvotes: 0
Views: 54
Reputation: 106012
The prototype
sortByLength(char *words[],int * lengths, const int size);
is equivalent to
sortByLength(char **words,int * lengths, const int size);
words[][20]
will converted to pointer to array of 20
char
s when passed to a function. char **
and char (*)[20]
are incompatible types. Change function prototype to
sortByLength(char (*words)[20], int *lengths, const int size);
Upvotes: 2