初学C语言——结构(1)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct students{
char name[20];
char sex[4];
int age;
};
int main(int argc,const char * argv[]){
struct students * qq=malloc(sizeof(struct students));
strcpy(qq->name,"巧巧");
strcpy(qq->sex,"人");
qq->age=18;
printf("name=%s\tsex=%s\tage=%d\t",qq->name,qq->sex,qq->age);
free(qq);
return 0;
}
//运行失败