【发布时间】:2014-05-10 16:22:00
【问题描述】:
我有三个动态分配的char** 类型的数组,如何将它们添加到一个静态数组中?
我需要使用char*** 数组吗?
void memory_allocation (char ***array [3], int* limit)
{
int i; //loop control
for (i = 0; i < 3; i++)
{
array [i] = (char***) malloc (*limit * sizeof(char*));
if (array [i] == NULL) //must take malloc's failure to allocate memory into account
printf ("Memory allocation failed!\n");
exit (1);
}
}
【问题讨论】:
-
哪种语言?请适当地标记问题。 D、Go、C# 和 Rust 的答案各不相同。
-
你能证明你的努力吗?
-
一个char**数组是char **array[3],不是char ***array[3];那将是一个 char*** 数组。
-
谢谢老兄(吉姆),我太笨了……
-
@Jim 它是一个“原始指针”,
[3]是函数参数列表中*的替代语法