初學(xué)C語(yǔ)言——結(jié)構(gòu)(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;
}
//運(yùn)行失敗