C言語

構造体

#include <stdio.h>

struct student{
	char *name;
	int age;
};
struct student makeSt(char *, int);

void func(struct student);

int main(void){
	struct student taro;
	taro = makeSt("Taro", 30);
	func(taro);
	return 0;
}

void func(struct student boys){
	printf("%s %d\n", boys.name, boys.age);
}

struct student makeSt(char *name, int age){
	struct student newcomer;
	newcomer.name = name;
	newcomer.age = age;
	
	return newcomer;
}