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;
{
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的内存没有分配。
梦想与现实的落差,就是我们离成功的距离~