typedef struct
{
        int id;
        char username [6];
} user;

int main(void)
{
        user *userr;
        strncpy(userr->username, "hello", 3);
        strcat(userr->username, ""0");
        printf("userr->username=%s."n", userr->username);

        return 0;

}

 

便已没有错误 运行时候有错误。 Userr的内存没有分配。

相关文章:

  • 2021-05-18
  • 2021-09-26
  • 2021-10-26
  • 2021-07-05
  • 2022-12-23
  • 2022-12-23
  • 2023-01-05
  • 2021-09-15
猜你喜欢
  • 2022-12-23
  • 2021-11-21
  • 2021-11-23
  • 2021-11-15
  • 2022-12-23
  • 2022-12-23
  • 2021-08-23
相关资源
相似解决方案