更新时间:2022-05-12 05:50:10
您已将strArray
定义为char*
的数组(即,指向字符串的指针),但是分配的大小为N *单个字符.我怀疑你的意思是
You have definedstrArray
as an array ofchar*
(i.e. pointers to character strings) but your allocation is of N * the size of a single character. I suspect what you meant was
char ** strArray = (char **)malloc(N * sizeof(char*));
然后,您可以使用诸如
的分配
Then you could use an assignment such as
strArray[1] = str; // save the address of this string to strArray
是的....我在那里犯了一个可怕的错误.谢谢帕里尼(Thanx Pallini).
Yes....I made a terrible mistake there. Thanx Pallini.