{"id":332,"date":"2023-02-22T02:39:24","date_gmt":"2023-02-22T10:39:24","guid":{"rendered":"http:\/\/bitas.net.cn\/?page_id=332"},"modified":"2023-02-22T02:39:34","modified_gmt":"2023-02-22T10:39:34","slug":"121-2","status":"publish","type":"page","link":"http:\/\/bitas.net.cn\/index.php\/sourcecode\/121-2\/","title":{"rendered":"121 \u7981\u6b62\u5f15\u7528\u5df2\u91ca\u653e\u7684\u6307\u9488"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\n#include &lt;stdlib.h>\n#include &lt;string.h>\n\ntypedef struct tagIDCard {\n    long serialNo;\n    char name&#91;32];\n} IDCard;\n\nIDCard *make_idcard(long serialNo, char *name)\n{\n    IDCard *id;\n    if ((id = malloc(sizeof(IDCard))) == NULL)\n        return NULL;\n    id->serialNo = serialNo;\n    strcpy(id->name, name);\n    return id; \n}\n\nvoid print_idcard(IDCard *id)\n{\n    if (id) {\n        printf(\"%20s: %ld\\n\"\n                \"%20s: %s\\n\",\n                \"ID SerialNo.\", id->serialNo,\n                \"ID name\", id->name);\n    }   \n}\n\nint main(int argc, char *argv&#91;])\n{\n    IDCard *id = make_idcard(200401L, \"x401\");\n    printf(\"sizeof IDCard object: %ld\\n\",\n        sizeof(*id));\n    if (id) {\n        print_idcard(id);\n        free(id);\n        printf(\"*** id has been freed\\n\");\n        print_idcard(id);\n    }   \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-332","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/pages\/332","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=332"}],"version-history":[{"count":1,"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/pages\/332\/revisions"}],"predecessor-version":[{"id":333,"href":"http:\/\/bitas.net.cn\/index.php\/wp-json\/wp\/v2\/pages\/332\/revisions\/333"}],"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=332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}