c中的char *数组

时间:2017-05-10 16:04:58

标签: c arrays

我试图传递一个用大括号和静态字符串定义的char *数组,我希望将它作为参数传递给函数。

阵列是下一个:

char * phrase[] = {"my", "name", "is", "John"};

并且将接收参数的函数实现如下:

void composeList(char * phrase[]){
  //I'm getting the size of the list
  int phrase_list_size = sizeof(*phrase)/sizeof(phrase[0]);
  printf("%d\n",phrase_list_size);
}

我以这种方式调用该函数:

composeList(phrase);

但是当我打印尺寸时,该值为1而不是4.你能帮助我吗?

0 个答案:

没有答案
相关问题