C语言之指针、数组和函数

2014-11-23 22:03:16 · 作者: · 浏览: 28

while (p = getline(pFile))
{
 if (ulCurrLines >= ulAllocedLines)
 {
  // * 当前竖向空间已经不够了,通过realloc对其进行扩展。
 ulAllocedLines += 50; // 每次扩展50行。
  ppText = realloc (ppText, ulAllocedLines * (char *));
  if (NULL == ppText)
  {
   return; // 内存分配失败,返回
  }
 }
 ppText[ulCurrLines++] = p; // 横向“扩展”,指向不定长字符串
}