#define _CRT_SECURE_NO_DEPRECATE
#include
#include
#include
struct Student
{
char* Name;
char* Number;
char* Phone;
char Sex;
int BirthYear;
char* SexStr;
void init(char* name, char* number, char* phone, int sex, int birthYear)
{
Name = name;
Number = number;
Phone = phone;
Sex = sex;
BirthYear = birthYear;
SexStr = (char*)malloc(2 * sizeof(char));
switch (sex)
{
case 0:
sprintf(SexStr, "?); break;
case 1:
sprintf(SexStr, "?); break;
}
printf("Base address = %0.8X\n", this);
printf("€tudent%d\n", sizeof(Student));
}
int getAge()
{
time_t timep;
tm *p;
time(timep);
p = gmtime(timep); //ゅtm
int Year = 1900 + p->tm_year;
return Year - BirthYear;
}
void introduce()
{
printf("у%s,%s,%d€%s?s\n", Name, SexStr, getAge(), Number, Phone);
}
};
void main()
{
Student student;
student.init("?, "2017174", "13760855621", 0, 1988);
student.introduce();
system("pause");
}