{"id":3402,"date":"2017-07-14T21:54:20","date_gmt":"2017-07-14T13:54:20","guid":{"rendered":"https:\/\/ixyzero.com\/blog\/?p=3402"},"modified":"2017-07-15T10:37:18","modified_gmt":"2017-07-15T02:37:18","slug":"linux%e4%b8%8b%e7%9a%84c%e8%af%ad%e8%a8%80bzero%e5%92%8cmemset","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/3402.html","title":{"rendered":"Linux\u4e0b\u7684C\u8bed\u8a00#bzero\u548cmemset"},"content":{"rendered":"<p>=Start=<\/p>\n<h4 id=\"Linux\u4e0b\u7684C\u8bed\u8a00#bzero\u548cmemset-\u7f18\u7531\uff1a\">\u7f18\u7531\uff1a<\/h4>\n<p>\u6574\u7406\u5b66\u4e60\u5728\u8fdb\u884cLinux\u4e0bC\u7f16\u7a0b\u4e2d\u78b0\u5230\u7684\u4e00\u4e9b\u77e5\u8bc6\u70b9\uff0c\u65b9\u4fbf\u4ee5\u540e\u8fdb\u884c\u53c2\u8003\u3002<\/p>\n<h4 id=\"Linux\u4e0b\u7684C\u8bed\u8a00#bzero\u548cmemset-\u6b63\u6587\uff1a\">\u6b63\u6587\uff1a<\/h4>\n<h5 id=\"Linux\u4e0b\u7684C\u8bed\u8a00#bzero\u548cmemset-\u53c2\u8003\u89e3\u7b54\uff1a\">\u53c2\u8003\u89e3\u7b54\uff1a<\/h5>\n<p><span style=\"color: #ff0000;\"><strong>bzero \u548c memset \u5efa\u8bae\u4f7f\u7528 memset()<\/strong><\/span><br \/>\nvoid bzero(void *s, int n); \/\/<strong>\u975e\u6807\u51c6C\u51fd\u6570<\/strong>\uff0c\u7528\u4e8e\u5c06\u5b57\u7b26\u4e32s\u7684\u524dn\u4e2a\u5b57\u8282\u7f6e\u4e3a\u96f6<br \/>\nvoid *memset(void *s, int c, size_t n); \/\/<strong>\u6807\u51c6C\u51fd\u6570<\/strong>\uff0c\u7528\u4e8e\u628as\u6240\u6307\u5185\u5b58\u533a\u57df\u7684\u524dn\u4e2a\u5b57\u8282\u8bbe\u7f6e\u6210\u5b57\u7b26c<\/p>\n<p><a class=\"external-link\" href=\"https:\/\/stackoverflow.com\/questions\/17096990\/why-use-bzero-over-memset\" rel=\"nofollow\">https:\/\/stackoverflow.com\/questions\/17096990\/why-use-bzero-over-memset<\/a><br \/>\n<a class=\"external-link\" href=\"http:\/\/fdiv.net\/2009\/01\/14\/memset-vs-bzero-ultimate-showdown\" rel=\"nofollow\">http:\/\/fdiv.net\/2009\/01\/14\/memset-vs-bzero-ultimate-showdown<\/a><\/p>\n<p><a class=\"external-link\" href=\"https:\/\/stackoverflow.com\/questions\/18330673\/bzero-bcopy-versus-memset-memcpy\" rel=\"nofollow\">https:\/\/stackoverflow.com\/questions\/18330673\/bzero-bcopy-versus-memset-memcpy<\/a><br \/>\n\/\/ void bzero(void *s, size_t n);<br \/>\n#define bzero(s, n) memset((s), 0, (n))<\/p>\n<p>\/\/ void bcopy(const void *s1, void *s2, size_t n);<br \/>\n#define bcopy(s1, s2, n) memmove((s2), (s1), (n))<br \/>\n<a class=\"external-link\" href=\"http:\/\/c.biancheng.net\/cpp\/html\/2538.html\" rel=\"nofollow\">http:\/\/c.biancheng.net\/cpp\/html\/2538.html<\/a><br \/>\n<a class=\"external-link\" href=\"http:\/\/man7.org\/linux\/man-pages\/man3\/memset.3.html\" rel=\"nofollow\">http:\/\/man7.org\/linux\/man-pages\/man3\/memset.3.html<\/a><\/p>\n<h5 id=\"Linux\u4e0b\u7684C\u8bed\u8a00#bzero\u548cmemset-\u53c2\u8003\u94fe\u63a5\uff1a\">\u53c2\u8003\u94fe\u63a5\uff1a<\/h5>\n<ul>\n<li><a href=\"http:\/\/man7.org\/linux\/man-pages\/man3\/memset.3.html\">http:\/\/man7.org\/linux\/man-pages\/man3\/memset.3.html<\/a><\/li>\n<li><a href=\"http:\/\/man7.org\/linux\/man-pages\/man3\/bzero.3.html\">http:\/\/man7.org\/linux\/man-pages\/man3\/bzero.3.html<\/a><\/li>\n<\/ul>\n<p>=END=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>=Start= \u7f18\u7531\uff1a \u6574\u7406\u5b66\u4e60\u5728\u8fdb\u884cLinux\u4e0bC\u7f16\u7a0b\u4e2d\u78b0\u5230\u7684\u4e00\u4e9b\u77e5\u8bc6\u70b9\uff0c\u65b9\u4fbf\u4ee5\u540e\u8fdb\u884c\u53c2\u8003\u3002 \u6b63\u6587\uff1a \u53c2\u8003\u89e3 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11,7],"tags":[848,100,30,849],"class_list":["post-3402","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-linux","category-programing","tag-bzero","tag-c","tag-linux","tag-memset"],"views":3583,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/3402","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=3402"}],"version-history":[{"count":3,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/3402\/revisions"}],"predecessor-version":[{"id":3419,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/3402\/revisions\/3419"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=3402"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=3402"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=3402"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}