Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在 C 中做 - 指向字符串的指针数组?因为字符串表示为字符数组,所以我尝试这样做:(假设每个字符串最大为 10 个字符,数组大小为 100)
char[10]* array[100];
但这是错误的
有什么建议吗?
正如 Adriano 所说,在 C 中,main 函数包含一个字符串数组:
int main(int argc, char* argv[]) { [...] }
argv是一个字符串数组,并且已正确声明。 收到。(如果您遇到问题,请提出具体、详细的问题)
argv
对于静态分配:
char buf[10][100];
对于动态分配:
char *buf[10];
并在其后分配:
buf[5] = strdup("Hello");