1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| #include <stdio.h> #include <string.h>
typedef struct Books { char title[50]; char author[50]; char subject[50]; int book_id; } Book,*BookPointer;
int main() { Book book; struct Books book_s;
strcpy(book_s.title, "book_s标题"); strcpy(book_s.author, "book_s作者Felix CAI"); strcpy(book_s.subject, "book_s编程语言"); book_s.book_id = 12340;
strcpy(book.title, "C 语言回忆"); strcpy(book.author, "Felix CAI"); strcpy(book.subject, "编程语言"); book.book_id = 56789;
BookPointer myBookPointer = &book; struct Books *BookPointers = &book_s; printf("myBookPointer的id : %d\n", myBookPointer->book_id); printf("BookPointers : %d\n", BookPointers->book_id); printf("\n"); printf("书标题 : %s\n", book.title); printf("书作者 : %s\n", book.author); printf("书类目 : %s\n", book.subject); printf("书 ID : %d\n", book.book_id); printf("\n"); printf("book_s书标题 : %s\n", book_s.title); printf("book_s书作者 : %s\n", book_s.author); printf("book_s书类目 : %s\n", book_s.subject); printf("book_s书 ID : %d\n", book_s.book_id);
return 0; }
|