strcat 函数给出分段错误

时间:2021-07-10 09:22:44

标签: c string-literals strcat

为什么这段代码会出现分段错误,是因为我使用了指针而不是数组吗?

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

//Compiler version gcc  6.3.0

int main()
{
  char *text1 ="I am";
  char *text2 ="an Indian";
  strcat(text1,text2);
  printf("%s",text1);
  return 0;
}

0 个答案:

没有答案
相关问题