Wednesday, May 4, 2016

Print Birthdate Use Structure C

#include <stdio.h>
#include <stdlib.h>

int main()
{
struct date{
int year;
int month;
int day;
};
struct person {
char name[100];
struct date birthday;
};
struct person friend1;
strcpy(friend1.name,"jake orchar");
friend1.birthday.year=1985;
friend1.birthday.month=12;
friend1.birthday.day=5;
struct person friend2;
strcpy(friend2.name,"tan zhi xin");
friend2.birthday.year=1992;
friend2.birthday.month=8;
friend2.birthday.day=16;
printf(" my friend name is \"%s\", his birth date at %d/%d/%d.\n",
friend1.name,friend1.birthday.day,friend1.birthday.month,friend1.birthday.year);
printf(" Next my friend name is \"%s\", her birth date at %d/%d/%d.\n",
friend2.name,friend2.birthday.day,friend2.birthday.month,friend2.birthday.year);
return 0;
}


No comments:

Post a Comment