Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- void printMe(int i) {
- printf("%d\n", i);
- }
- void printMe(const char * str) {
- printf("%s\n", str);
- }
- typedef struct person_s {
- char const * firstName;
- char const * lastName;
- int yearOfBirth;
- } person_t;
- typedef struct book_s {
- char const * title;
- person_s const * author;
- int numOfPages;
- } book_t;
- void printMe(person_t const * person) {
- printf("person.firstName : %s\n", person->firstName);
- printf("person.lastName : %s\n", person->lastName);
- printf("person.yearOfBirth : %d\n", person->yearOfBirth);
- }
- void printMe(book_s const * book) {
- printf("book.title : %s\n", book->title);
- printf("book.numOfPages : %d\n", book->numOfPages);
- printf("book.author : \n");
- printMe(book->author);
- }
- // -----------------
- int main() {
- printMe(42);
- printMe("hello");
- person_t johnDoe = { .firstName = "John", .lastName = "Doe",
- .yearOfBirth = 1900 };
- printMe(&johnDoe);
- person_t melville = { .firstName = "Herman", .lastName = "Melville",
- .yearOfBirth = 1819 };
- book_t mobyDick = { .title = "Moby Dick", .author = &melville,
- .numOfPages = 500 };
- printMe(&mobyDick);
- return 0;
- }
Add Comment
Please, Sign In to add comment