指针“char ** strData”指向哪里?

问题描述 投票:0回答:1

从代码here第12行有指针char **strData = NULL;。我是C和指针的新手。我知道,它是一个指向另一个指针的指针。我只是没有看到另一个指针。

有人能帮助我吗?

c pointers pointer-to-pointer
1个回答
3
投票

strData = (char**)realloc(strData, sizeof(char**)*(noOfLines+1));处于while循环中,因此strData指向一个可以保存指针的内存块。 sizeof(char**)应该是sizeof(char*)

接下来是strData[noOfLines] = (char*)calloc(MAX_LEN,sizeof(char));,这是你要求的指针。

所以qazxsw poi指向一个指针块,qazxsw poi指向一块strDatas。

© www.soinside.com 2019 - 2024. All rights reserved.