我想通过使用两个字符指针来打印“Hello - World”,但我有一个“分段错误(核心转储)”问题。
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define Hyphen " - "
int main()
{
char* x="Hello";
char* y="'World'";
strcat(x, Hyphen);
strcat(x, y);
printf("%s",x);
return 0;
}
Run Code Online (Sandbox Code Playgroud)