数据结构的简单学习1

来源:互联网 发布:影驰gtx960大将优化 编辑:程序博客网 时间:2024/05/16 06:02
#include<stdio.h>#include<string.h>#include<malloc.h>typedef struct{char name[10];//姓名unsigned int age;//年龄}people;void main(){char *tempName;int age;people stu;printf("Please enter the following information(name,years):\n ");tempName=(char*)malloc(sizeof(char)*10);//#分配内存给tempNamescanf("%s %d",tempName,&age);stu.age=age;strcpy(stu.name,tempName);printf("Name=%s,Age=%d\n",stu.name,stu.age);free(tempName);//#释放内存}

我写了一个小程序,主要功能就是利用一个结构体存储信息。
0 0
原创粉丝点击