二维字符数组与char** 关系 收藏
数组和指针联系很紧密,数组名的含义至少有两种含义:
1. 对应数据中的第一个元素的地址,
2. sizeof为数组大小,而不是指针大小
注:《c专家编程》中有详细介绍
指针使用经验总结.pdf 中也有相关内容
编程中,需要向某个函数传递一个字符串数组。测试代码如下:
view plaincopy to clipboardprint?
·········10········20········30········40········50········60········70········80········90········100·······110·······120·······130·······140·······150
#include <stdio.h>
#define M 2
#define N 100
void test(const char** pstr)
{
int i = 0;
for(i = 0; i < 2; i++)
{
printf("array[%d]= %s/n", i,*(pstr+i));
}
return;
}
int main()
{
char char_array[M][N] = {"a.txt", "b.txt"};
test((const char**) char_array);
re