为什么使用strcat之后出现堆已损坏异常

为什么使用strcat之后出现堆已损坏错误
初学菜鸟,想要修改txt文件中的内容,计划先打开文件,打开文件后将文件中的内容修改后存储在一个char型的指针变量中,可是每次修改数据后用strcat函数将修改后的数据存储在char指针中报堆已损坏错误。查了一下strcat函数原型,源字符串要有足够的空间容纳目的字符串,因此我每次都会为char指针重新分配空间,并且都分配成功了,可是每次用strcat连接字符串的时候还是会报错,这是什么原因?(不要告诉我怎么修改txt, 只需告诉我使用strcat后为什么会报错即可)

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ERROR 0
void main()
{
FILE *fp;
static int iLine = 0;
char * pStr,* pContent;
int iLength = 0, i = 0;
pStr = (char *)malloc(sizeof(char)*100);
pContent = (char *)malloc(sizeof(char));
/*打开源文件*/
fp = fopen("F:\\VSProjects\\ConsoleApplication2\\math.txt","r");
if (NULL == fp)
{
printf("Open File  Failed......");
exit(-1);
}
fgetc(fp);
while(!feof(fp))
{
if (fp == ERROR )
{
fclose(fp);
}
memset(pStr, 0, 100);
fgets(pStr, 100, fp);
iLine++;
}
fclose(fp);
fp = fopen("F:\\VSProjects\\ConsoleApplication2\\math.txt","r");
while(i < iLine)
{
if (fp == ERROR )
{
fclose(fp);
}
i++;
memset(pStr, 0, 100);
fgets(pStr, 100, fp);
if(i == 1)
{
pStr[27] = '0';
pStr[29] = '1';
}
else
{
if (pStr[27] == '.')
{
if (pStr[28] == '9')
{
pStr[28] = '0';
pStr[26] = (char)((int)pStr[26] + 1);
}
else
{
pStr[28] = (char)((int)pStr[28] + 1);
}
}
else{
if (pStr[29] == '9')
{
pStr[29] = '0';
pStr[27] = (char)((int)pStr[27] + 1);
}
else
{
pStr[29] = (char)((int)pStr[29] + 1);
}
}
}
pContent = (char *)realloc(pContent, strlen(pContent) + strlen(pStr));
printf("\n pStrLength = %d", strlen(pStr));
if (pContent != NULL)
{
printf(" Relloc Success, now Content Size is %d byte", strlen(pContent));
}
else
{
printf(" Relloc Failed");
}
strcat(pContent, pStr);
}
fclose(fp);
/* fp = fopen("F:\\VSProjects\\ConsoleApplication2\\math.txt","w");
fprintf(fp, "%s", content);
fclose(fp); */
free(pStr);
printf("\n");
system("pause");
}
------解决思路----------------------
楼主,你有没有考虑'\0'

pContent = (char *)realloc(pContent, strlen(pContent) + strlen(pStr) + 1);