Last active
October 11, 2015 19:18
-
-
Save kawa-/3907170 to your computer and use it in GitHub Desktop.
Object Oriented C lang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# just wrote them. | |
# ふと思いついたので書いてみた。これでOOPなCじゃんっていう。継承とか出来ないけど。 | |
#include <stdio.h> | |
struct person { | |
double height; | |
double weight; | |
int age; | |
char* name; | |
char* description; | |
}; | |
void person_print_infomation(struct person someone) | |
{ | |
printf("-----\nHeight: %.1f\nWeight: %.1f\nAge: %d\nName: %s\nDesc: %s\n-----\n", someone.height, someone.weight, someone.age, someone.name, someone.description); | |
} | |
void person_print_bmi(struct person someone) | |
{ | |
printf("BMI of %s is %.1f.\n",someone.name, someone.weight * someone.weight / someone.height); | |
} | |
int main (int argc, const char * argv[]) { | |
struct person ichiro = { | |
180.3, | |
71, | |
38, | |
"Ichiro", | |
"MLB Player" | |
}; | |
person_print_infomation(ichiro); | |
person_print_bmi(ichiro); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment