为何运行后,提示variable was corrupted?
在VS2005中运行如下程序,运行结果正确,但弹出提示“Run-Time Check Failure #2 - Stack around the variable 'p1' was corrupted.”,不知道为什么。#include "stdafx.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "conio.h"void main()
{
char p1[20],p2[20];
printf("string 1:");
gets(p1);
printf("\nstring2:");
gets(p2);
strcat(p1,p2);
printf("new string:%s",p1);
getch();
}
输入的是“Hello world”和“I love you”
在TC中运行正常,没有错误提示。
请帮忙解答一下原因,谢谢!