【发布时间】:2015-05-27 07:56:17
【问题描述】:
我正在尝试将此数组发送到函数sortByLength。
函数原型是
sortByLength(char *words[],int * lengths, const int size);
这是我尝试将其传递给函数的其余代码:
#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;
}
【问题讨论】:
-
你有什么问题?
-
为什么不 sortByLength(words, lengths, SIZE);
-
@kiks73 这行不通。因为他将其声明为二维数组。但他把它当作指针的指针。
-
@Karthikeyan.R.S;它不是指针数组,而是指向指针的指针。
-
@hacks so 'char words[][20]' 是指向指向第一个元素“Sun”的指针的指针?
标签: c string function multidimensional-array