一个malloc问题.
首先,我生成一些字符串.
第二,我为复制指向那些字符串的指针分配无空间.此时程序应该崩溃,因为我试图将这些指针复制到任何地方,但它不会崩溃.这怎么可能?
任何意见将不胜感激.
#include <stdio.h>
int main(int argc, char *argv[])
{
int i,
iJ,
iCharCount = 0,
iCharVal,
iStrLen = 0,
iStrNum = 50,
iStrCount = 0,
iAllocSize = 0;
char *pcStr,
*pcStr_CurPos,
**ppcStr,
**ppcStr_CurPos;
// suppose, an average length of string is * N bytes.
iAllocSize = iStrNum * 6;
iStrCount = 0;
// allocate ...
pcStr = pcStr_CurPos = (char*) malloc (iAllocSize);
if (pcStr==NULL){printf("NULL == malloc()\n"); exit (1);}
for (i=0; i < iStrNum; i++)
{
iStrCount++;
iStrLen …Run Code Online (Sandbox Code Playgroud)