为什么这段代码导致运行时错误?

Amo*_*wal 1 c buffer-overflow

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
  char *a = "Hello ";
  const char *b = "World";

  printf("%s", strcat(a, b));
  system("PAUSE");

  return EXIT_SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)

Did*_*set 7

因为您在不拥有的内存位置写入数据.

实际上,在运行strcat时,您将在字符串a的字符后面追加字符串b的字符.但你没有声称字符串后的内存.