⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bdays.c

📁 C.Game.Programming.For.Dummies.原码
💻 C
字号:
#include <stdio.h>
#include <stdlib.h>

    struct date {
        int month;
        int day;
        int year;
        };

    struct family {
        char name[20];
        struct date birthday;
        };

struct family getdata(int member);
void print_data(struct family person);

void main()
{
    int x,f;
    char numb[3];
    struct family myfamily[10];

    printf("How many people in your family?");
    f = atoi(gets(numb));

    puts("Enter information about each family member");

    for(x=0;x<f;x++)
        myfamily[x] = getdata(x);

    puts("\nHere is your family data:");

    for(x=0;x<f;x++)
        print_data(myfamily[x]);
}

/* Fill in each "record" in the structure */

struct family getdata(int member)
{
    struct family new;
    int temp;           //temp integer storage
    char input[20];     //temp string storage

    printf("Family member %i:\n",member+1);

/* Get their name */

    printf("Name:");
    gets(new.name);

/* Get birthday info */

    puts("Birthday information:");

    printf("Month:");
    temp = atoi(gets(input));
    new.birthday.month = temp;

    printf("Day:");
    temp = atoi(gets(input));
    new.birthday.day = temp;

    printf("Year:");
    temp = atoi(gets(input));
    new.birthday.year = temp;

    return(new);
}

void print_data(struct family person)
{
    printf("%s was born on %i/%i/%i\n",\
        person.name,\
        person.birthday.month,\
        person.birthday.day,\
        person.birthday.year);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -