我在 C(不是 C++)中有一个 char 数组。类型是 char**。我知道它的长度,但元素的长度是未知的。 我还有另一个 char* 数组。 需要将此 char* 作为最后一个元素附加到我的 char**。
最佳答案
char* arr1[]; //known length with some already filled elements
上述数组的每个元素都是一个指向字符数组的指针。
char *new = "lastElem" // this is the string you have to append
假设,arr1 有 n 个元素(每个元素都是一个字符串)。然后,
arr1[++n] = new; // this should do it, provided space exists in arr1 and you already have the //character array 'new'.
关于c - 如何在 C 中将 char* 添加到 char**,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14184157/