您的位置:首页 > 其它

crazy pointer

2016-05-04 09:01 260 查看
#include <stdio.h>
#include <malloc.h>
#include <string.h>
struct Student
{
char* name;
int age;
};

int main(int argc,char* argv[])
{
struct Student s;

//s.name = (char*)malloc(sizeof(char)*20);  //少了这句,就会使s.name变成野指针

strcpy(s.name,"LI");

s.age = 23;

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: