
Read it right next to your computer.
Book version bitter C
void student_print(student data)
void student_print(student data)
{
printf("[学year]:%d\n", data.year);
printf("[クラス]:%d\n", data.clas);
printf("[出席番号]:%d\n", data.number);
printf("[名前]:%s\n", data.name);
printf("[身長]:%f\n", data.stature);
printf("[体重]:%f\n", data.weight);
return;
}
#include <stdio.h>
#include <string.h>
typedef struct
{
int year; /* 学year */
int clas; /* クラス */
int number; /* 出席番号 */
char name[64]; /* 名前 */
double stature; /* 身長 */
double weight; /* 体重 */
} student;
void student_print(student data);
int main(void)
{
student data;
data.year = 3;
data.clas = 4;
data.number = 18;
strcpy(data.name, "MARIO");
data.stature = 168.2;
data.weight = 72.4;
student_print(data); /* 呼び出し */
return 0;
}
void student_print(student data)
{
printf("[学year]:%d\n", data.year);
printf("[クラス]:%d\n", data.clas);
printf("[出席番号]:%d\n", data.number);
printf("[名前]:%s\n", data.name);
printf("[身長]:%f\n", data.stature);
printf("[体重]:%f\n", data.weight);
return;
}
#include <stdio.h>
#include <string.h>
typedef struct
{
int year; /* 学year */
int clas; /* クラス */
int number; /* 出席番号 */
char name[64]; /* 名前 */
double stature; /* 身長 */
double weight; /* 体重 */
} student;
int main(void)
{
student data;
student *pdata;
pdata = &data; /* Initialization */
(*pdata).year = 10; /* normalvariableモードへの切り替え */
strcpy((*pdata).name, "MARIO"); /* normalvariableモードへの切り替え */
return 0;
}
(*structPointer variables名).要素名
structPointer variables名->要素名
int main(void)
{
student data;
student *pdata;
pdata = &data; /* Initialization */
pdata->year = 10; /* ->symbolによるアクセス */
strcpy(pdata->name, "MARIO"); /* ->symbolによるアクセス */
return 0;
}
#include <stdio.h>
#include <string.h>
typedef struct
{
int year; /* 学year */
int clas; /* クラス */
int number; /* 出席番号 */
char name[64]; /* 名前 */
double stature; /* 身長 */
double weight; /* 体重 */
} student;
void student_print(student *data);
int main(void)
{
student data;
data.year = 3;
data.clas = 4;
data.number = 18;
strcpy(data.name, "MARIO");
data.stature = 168.2;
data.weight = 72.4;
student_print(&data); /* addressで呼び出す */
return 0;
}
void student_print(student *data)
{
printf("[学year]:%d\n", data->year); /* ->symbolでアクセス */
printf("[クラス]:%d\n", data->clas);
printf("[出席番号]:%d\n", data->number);
printf("[名前]:%s\n", data->name);
printf("[身長]:%f\n", data->stature);
printf("[体重]:%f\n", data->weight);
return;
}
Reasons for passing a struct that could be passed by value as a pointer variable.
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.