{"id":292,"date":"2023-02-22T02:19:24","date_gmt":"2023-02-22T10:19:24","guid":{"rendered":"http:\/\/bitas.net.cn\/?page_id=292"},"modified":"2023-02-22T02:19:31","modified_gmt":"2023-02-22T10:19:31","slug":"101-2","status":"publish","type":"page","link":"http:\/\/bitas.net.cn\/index.php\/sourcecode\/101-2\/","title":{"rendered":"101 \u7ed3\u6784\u4f53\u7684\u521d\u59cb\u5316\u4e0e\u5b58\u53d6"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\n#include &lt;stdlib.h>\n#include &lt;string.h>\n\n#if 0\nstruct tagIDCard {\n    long serialNo;    \/\/ 6\u4f4d\u6570\u7684\u5e8f\u5217\u53f7\n    char name&#91;32];    \/\/ \u540d\u79f0\n};\n\nstruct tagStudent {\n    char gender;    \/\/ F or M\n    unsigned short age;\n    struct tagIDCard id;\n};\n#else\ntypedef struct tagIDCard {\n    long serialNo;    \/\/ 6\u4f4d\u6570\u7684\u5e8f\u5217\u53f7\n    char name&#91;32];    \/\/ \u540d\u79f0\n} IDCard;\n\ntypedef struct tagStudent {\n    char gender;    \/\/ F or M\n    unsigned short age;\n    IDCard id; \n} Student;\n#endif\n\nvoid print_student(Student *ps)\n{\n    if (ps) {\n        if (ps->id.serialNo &lt; 200000)\n            ps->id.serialNo += 200000;\n        printf(\"%15s: %c\\n\"\n            \"%15s: %hd\\n\"\n            \"%15s: %ld\\n\"\n            \"%15s: %s\\n\",\n            \"Gender\", ps->gender,\n            \"Age\", ps->age,\n            \"ID SerialNo.\", ps->id.serialNo,\n            \"ID name\", ps->id.name);\n    }   \n}\n\nint main(int argc, char *argv&#91;])\n{\n    IDCard id101 = { 200101, \"x1\" };\n    Student student = {\n        'M',\n        21,\n        { 0, \"\" }\n    };\n    student.id.serialNo = 200100;\n    strcpy(student.id.name, \"x\");\n    print_student(&amp;student);\n    student.id = id101;\n    print_student(&amp;student);\n    return 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":127,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-292","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/pages\/292","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/comments?post=292"}],"version-history":[{"count":1,"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/pages\/292\/revisions"}],"predecessor-version":[{"id":293,"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/pages\/292\/revisions\/293"}],"up":[{"embeddable":true,"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/pages\/127"}],"wp:attachment":[{"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/media?parent=292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}