编译环境 vs2008
源代码如下:
// Structrue.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <Windows.h>
typedef struct _STRUDENT{
int number;
char *name;
int age;
bool isMale;
}Student,*pStudent;
void PrintStudent(Student student)
{
printf("%d\n",student.number);
printf("%s\n",student.name);
printf("%d\n",student.age);
if (student.isMale)
{
printf("is a male");
}
else
{
printf("is a female");
}
}
int _tmain(int argc, _TCHAR* argv[])
{
Student xiaoma;
xiaoma.number=0x51303;
xiaoma.name="xiaoma";
xiaoma.age=0x21;
xiaoma.isMale=true;
PrintStudent(xiaoma);
getchar();
return 0;
}
运行结果为:
