#include <stdlib.h>
#include <stdio.h>
void test(char *str[], int size)
{
int i;
printf("sizeof(str) = %d\n", sizeof(str));//退化成指针
for (i = 0; i < size; i++)
{
printf("%s\n", str[i]);
}
}
int main()
{
char *str[] = {"test0", "test1", "test2"};
int size = sizeof(str)/sizeof(char *); // str为数组名,sizeof(str)可得数组大小
printf("sizeof(str) = %d\n", sizeof(str));
test(str, size);
return 0;
}
C语言之使用指针数组传递参数
最新推荐文章于 2024-10-11 20:13:52 发布