您的位置:首页 > 理论基础 > 数据结构算法

数据结构的简单学习1

2013-12-20 18:13 197 查看
#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);			//#分配内存给tempName
	scanf("%s %d",tempName,&age);
	stu.age=age;
	strcpy(stu.name,tempName);
	printf("Name=%s,Age=%d\n",stu.name,stu.age);

	free(tempName);									//#释放内存
}


我写了一个小程序,主要功能就是利用一个结构体存储信息。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: