
Read it right next to your computer.
Book version bitter C
#include <stdio.h>
#include <string.h>
typedef struct {
char name[256];
int age;
int sex;
} People;
void InputPeople(People* data)
{
printf("名前:");
scanf("%s", data->name);
printf("year齢:");
scanf("%d", &data->age);
printf("性別(1-男性、2-女性):");
scanf("%d", &data->sex);
printf("\n");
}
void ShowPeople(People data)
{
char sex[16];
printf("名前:%s\n", data.name);
printf("year齢:%d\n", data.age);
if (data.sex == 1) {
strcpy(sex, "男性");
} else {
strcpy(sex, "女性");
}
printf("性別:%s\n", sex);
printf("\n");
}
/* People.h */
#ifndef __PEOPLE_H__
#define __PEOPLE_H__
#include <stdio.h>
#include <string.h>
typedef struct {
char name[256];
int age;
int sex;
} People;
/* 個人データを入力する */
extern void InputPeople(People* data);
/* 個人データを表示する */
extern void ShowPeople(People data);
#endif
/* People.c */
#include "People.h"
void InputPeople(People* data)
{
printf("名前:");
scanf("%s", data->name);
printf("year齢:");
scanf("%d", &data->age);
printf("性別(1-男性、2-女性):");
scanf("%d", &data->sex);
printf("\n");
}
void ShowPeople(People data)
{
char sex[16];
printf("名前:%s\n", data.name);
printf("year齢:%d\n", data.age);
if (data.sex == 1) {
strcpy(sex, "男性");
} else {
strcpy(sex, "女性");
}
printf("性別:%s\n", sex);
printf("\n");
}
Learning C language through suffering (Kushi C) is
This is the definitive introduction to the C language.
It systematically explains the basic functions of the C language.
The quality is equal to or higher than commercially available books.