{"id":2871,"date":"2009-06-10T03:08:53","date_gmt":"2009-06-10T03:08:53","guid":{"rendered":"http:\/\/www.happyfam.or.kr\/ysoh\/c%ec%96%b8%ec%96%b4%ec%97%90%ec%84%9c-%ea%b0%80%eb%b3%80-%ed%8c%8c%eb%9d%bc%eb%a9%94%ed%84%b0%eb%a5%bc-%ea%b0%80%ec%a7%80%eb%8a%94-%ed%95%a8%ec%88%98\/"},"modified":"2015-02-10T21:12:15","modified_gmt":"2015-02-10T12:12:15","slug":"c%ec%96%b8%ec%96%b4%ec%97%90%ec%84%9c-%ea%b0%80%eb%b3%80-%ed%8c%8c%eb%9d%bc%eb%a9%94%ed%84%b0%eb%a5%bc-%ea%b0%80%ec%a7%80%eb%8a%94-%ed%95%a8%ec%88%98","status":"publish","type":"post","link":"https:\/\/www.happyfam.or.kr\/ysoh\/c%ec%96%b8%ec%96%b4%ec%97%90%ec%84%9c-%ea%b0%80%eb%b3%80-%ed%8c%8c%eb%9d%bc%eb%a9%94%ed%84%b0%eb%a5%bc-%ea%b0%80%ec%a7%80%eb%8a%94-%ed%95%a8%ec%88%98\/","title":{"rendered":"C\uc5b8\uc5b4\uc5d0\uc11c \uac00\ubcc0 \ud30c\ub77c\uba54\ud130\ub97c \uac00\uc9c0\ub294 \ud568\uc218"},"content":{"rendered":"<p><P>\uc21c\uc218 C\uc5b8\uc5b4 \ud568\uc218\ub294 \uc77c\ubc18\uc801\uc73c\ub85c \ud568\uc218 \ud30c\ub77c\uba54\ud130\uc758 \uac2f\uc218\uac00 \uace0\uc815\uc801\uc774\uace0 OOP\uc5d0\uc11c \ubcf4\uc774\ub294 \uc624\ubc84\ub85c\ub529\uacfc \uac19\uc774 \ud558\ub098\uc758 \ud568\uc218\uc774\ub984\uc73c\ub85c \uc11c\ub85c \ub2e4\ub978 \ud30c\ub77c\uba54\ud130\ub97c \uac00\uc9c0\ub294 \ud568\uc218\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc5c6\ub2e4. \uadf8\ub7f0\ub370 C\uc5b8\uc5b4 \ud568\uc218 \uc911 printf()\ub958\uc758 \ud568\uc218\ub294 \ud30c\ub77c\uba54\ud130\uac00 \ucd5c\uc18c 1 \uac1c \uc774\uc0c1\uc73c\ub85c \uac00\ubcc0\uc801\uc774\ub2e4. \uc608\ub97c \ub4e4\uba74 \uc544\ub798 printf \ud568\uc218\ub294 \ub3d9\uc77c\ud55c \uacb0\uacfc\ub97c \ucd9c\ub825\ud558\uc9c0\ub9cc \uc0ac\uc6a9\ud55c \ud30c\ub77c\uba54\ud130\uc758 \uac2f\uc218\ub294 \ub2e4\ub974\ub2e4. <BR><\/P><br \/>\n<DIV>printf(&#8220;Hello World!&#8221;); \/* \ud30c\ub77c\uba54\ud130 1\uac1c \uc0ac\uc6a9 *\/ <BR>printf(&#8220;Hello %s!&#8221;, &#8220;World&#8221;); \/* \ud30c\ub77c\uba54\ud130 2\uac1c \uc0ac\uc6a9 *\/ <BR>printf(&#8220;%s %s!&#8221;, &#8220;Hello&#8221;, &#8220;World&#8221;); \/* \ud30c\ub77c\uba54\ud130 3\uac1c \uc0ac\uc6a9 *\/ <\/DIV><br \/>\n<P dir=\"ltr\"><BR>\uadf8\ub7ec\uba74 \uc5b4\ub5bb\uac8c \uc774\ub7f0 \ud568\uc218\ub97c \uc791\uc131\ud560 \uc218 \uc788\uc744\uae4c? \ud574\uacb0\ucc45\uc740 \ud5e4\ub354\ud30c\uc77c &#8220;stdarg.h&#8221;\uc5d0 \uc815\uc758\ub3fc \uc788\ub2e4. \uc774 \ud30c\uc77c\uc5d0 \ubcf4\uba74 va_list \ud0c0\uc785\uacfc \ub124 \uac00\uc9c0\uc758 \ub9e4\ud06c\ub85c va_start, va_arg, va_end, va_copy \uac00 \uc815\uc758\ub3fc \uc788\ub294\ub370, \uc774 \ub9e4\ud06c\ub85c\ub4e4\uc774 \uac00\ubcc0 \ud30c\ub77c\uba54\ud130\ub97c \ucc98\ub9ac\ud558\ub294\ub370 \uc0ac\uc6a9\ub41c\ub2e4. <BR><\/P><br \/>\n<DIV><STRONG>va_list<BR><\/STRONG>\uc774 \ud0c0\uc785\uc740 \uac00\ubcc0 \ud30c\ub77c\uba54\ud130\ub97c \uc704\ud55c \ub370\uc774\ud130 \ud0c0\uc785\uc73c\ub85c \uac00\ubcc0 \ud568\uc218 \uc815\uc758 \ubd80\ubd84\uc5d0\uc11c \uac00\ubcc0 \ud30c\ub77c\uba54\ud130\ub97c \ucc98\ub9ac\ud558\uae30 \uc704\ud574 \uc120\uc5b8\ud55c\ub2e4.<BR><BR><STRONG>void va_start(va_list ap, last);<BR><\/STRONG>\uc774 \ub9e4\ud06c\ub85c\ub294 \uac00\ubcc0 \ud30c\ub77c\uba54\ud130(ap)\uc758 \uc2dc\uc791\uc704\uce58\ub97c \ud568\uc218\uc5d0 \uc8fc\uc5b4\uc9c4 \ub9c8\uc9c0\ub9c9 \uace0\uc815 \ud30c\ub77c\uba54\ud130(last) \ub2e4\uc74c\uc73c\ub85c \ucd08\uae30\ud654 \ud574 \uc8fc\uba70, \uc77c\ubc18\uc801\uc73c\ub85c \ud568\uc218\uc758 \uccab \ubd80\ubd84\uc5d0 \uc0ac\uc6a9\ub41c\ub2e4.<BR><BR><STRONG>type va_arg(va_list ap, type);<BR><\/STRONG>\uc774 \ub9e4\ud06c\ub85c\ub294 \uac00\ubcc0 \ud30c\ub77c\uba54\ud130(ap) \uc5d0\uc11c \uc8fc\uc5b4\uc9c4 \ud0c0\uc785(type)\uc758 \uac12\uc744 \uc77d\uace0 \uac00\ubcc0 \ud30c\ub77c\uba54\ud130(ap)\uc758 \uc704\uce58\ub97c \ub2e4\uc74c\uc73c\ub85c \uc774\ub3d9\uc2dc\ud0a8\ub2e4.<BR><BR><STRONG>void va_end(va_list ap);<BR><\/STRONG>\uc774 \ub9e4\ud06c\ub85c\ub294 \ud568\uc218\uc758 \ub9c8\uc9c0\ub9c9 \ubd80\ubd84\uc5d0 \uc0ac\uc6a9\ud55c\ub2e4.<BR><BR><STRONG>void va_copy(va_list dest, va_list src);<BR><\/STRONG>\uc774 \ub9e4\ud06c\ub85c\ub294 src\uc5d0 \uc800\uc7a5\ub41c \uac00\ubcc0 \ud30c\ub77c\uba54\ud130\ub97c dest\ub85c \ubcf5\uc0ac\ud55c\ub2e4.<BR><\/DIV><br \/>\n<P dir=\"ltr\"><BR>\uadf8\ub9ac\uace0 \uac00\ubcc0 \ud568\uc218\ub97c \uc815\uc758\ud560 \ub54c \ucd5c\uc18c \ud55c \uac1c \uc774\uc0c1\uc758 \ud30c\ub77c\uba54\ud130\ub294 \ubc18\ub4dc\uc2dc \uc815\uc0c1\uc801\uc73c\ub85c &#8220;int a&#8221;\uc640 \uac19\uc774 \ud0c0\uc785\uacfc \ubcc0\uc218\uba85\uc744 \uc120\uc5b8\ud574\uc57c \ud558\uba70 \ub098\uba38\uc9c0 \uac00\ubcc0 \ud30c\ub77c\uba54\ud130 \ubd80\ubd84\uc740 &#8220;&#8230;&#8221;\uc73c\ub85c \uc120\uc5b8\ud558\uba74 \ub41c\ub2e4. \uc774 \ub54c &#8220;&#8230;&#8221;\uc740 \ud568\uc218 \ud30c\ub77c\uba54\ud130\uc758 \ub9e8 \ub9c8\uc9c0\ub9c9\uc5d0 \uc120\uc5b8\ud574\uc57c \ud55c\ub2e4.<BR><BR><BR>\uc0ac\uc6a9\ubc95\uc740 \uc544\ub798 \ud504\ub85c\uadf8\ub7a8\uc744 \ucc38\uc870\ud558\uc790. \uc544\ub798 \uc791\uc131\ud55c \ud504\ub85c\uadf8\ub7a8\uc758 \ud568\uc218 sum\uc740 \uac00\ubcc0 \ud30c\ub77c\uba54\ud130\ub97c \uac00\uc9c0\ub294 \ud568\uc218\ub85c, \uc8fc\uc5b4\uc9c4 \ud30c\ub77c\uba54\ud130\uc758 \uac12\uc774 -1\uc744 \ub9cc\ub0a0 \ub54c\uae4c\uc9c0 \ud30c\ub77c\uba54\ud130\uc5d0 \uc804\ub2ec\ub41c \uc815\uc218\uc758 \ud569\uc744 \uacc4\uc0b0\ud55c\ub2e4.<BR><\/P><br \/>\n<DIV>#include &lt;stdio.h&gt;<BR>#include &lt;<STRONG>stdarg.h<\/STRONG>&gt; <BR><BR>int sum_list(int a, <STRONG>&#8230;<\/STRONG>)<BR>{<BR>&nbsp; &nbsp; <STRONG>va_list<\/STRONG> ap; \/* \uac00\ubcc0 \ud30c\ub77c\uba54\ud130 \uc800\uc7a5\uc744 \uc704\ud55c \ubcc0\uc218 ap \uc120\uc5b8 *\/<BR>&nbsp; &nbsp; int i, sum = 0;<BR><BR>&nbsp; &nbsp; <STRONG>va_start<\/STRONG>(ap, a); \/* \uac00\ubcc0 \ud30c\ub77c\uba54\ud130\uac00 a \ub2e4\uc74c\ubd80\ud130 \uc2dc\uc791\ub428\uc744 \uc54c\ub9bc *\/<BR><BR>&nbsp; &nbsp; i = a;<BR>&nbsp; &nbsp; while(i != -1) {<BR>&nbsp; &nbsp; &nbsp; &nbsp; sum += i;<BR>&nbsp; &nbsp; &nbsp; &nbsp; i = <STRONG>va_arg<\/STRONG>(ap, int); \/* \uac00\ubcc0 \ud30c\ub77c\uba54\ud130\uc5d0\uc11c \uc815\uc218 \uac12\uc744 \uc77d\uace0 \ub2e4\uc74c \uac12\uc744 \uc77d\uae30 \uc704\ud574 \uc900\ube44 *\/<BR>&nbsp; &nbsp; }<BR><BR>&nbsp; &nbsp; <STRONG>va_end<\/STRONG>(ap); \/* \uac00\ubcc0 \ud30c\ub77c\uba54\ud130\ub97c \ub2e4 \uc0ac\uc6a9\ud568 *\/<BR><BR>&nbsp; &nbsp; return sum;<BR>}<BR><BR>int main(int argc, char *argv[])<BR>{<BR>&nbsp; &nbsp; printf(&#8220;%d\\n&#8221;, sum_list(<STRONG>-1<\/STRONG>)); \/* 0 \ucd9c\ub825 *\/<BR>&nbsp; &nbsp; printf(&#8220;%d\\n&#8221;, sum_list(1,<STRONG>-1<\/STRONG>)); \/* 1\ucd9c\ub825 *\/<BR>&nbsp; &nbsp; printf(&#8220;%d\\n&#8221;, sum_list(1,2,<STRONG>-1<\/STRONG>)); \/* 3 \ucd9c\ub825 *\/<BR>&nbsp; &nbsp; printf(&#8220;%d\\n&#8221;, sum_list(1,2,3,<STRONG>-1<\/STRONG>)); \/* 6\ucd9c\ub825 *\/<BR>&nbsp; &nbsp; printf(&#8220;%d\\n&#8221;, sum_list(1,2,3,4,<STRONG>-1<\/STRONG>)); \/* 10 \ucd9c\ub825 *\/<BR>&nbsp; &nbsp; printf(&#8220;%d\\n&#8221;, sum_list(1,2,3,4,5,<STRONG>-1<\/STRONG>)); \/* 15 \ucd9c\ub825 *\/<BR>&nbsp; &nbsp; printf(&#8220;%d\\n&#8221;, sum_list(1,2,3,4,5,6,<STRONG>-1<\/STRONG>)); \/* 21 \ucd9c\ub825 *\/<BR>&nbsp; &nbsp; printf(&#8220;%d\\n&#8221;, sum_list(1,2,3,4,5,6,7,<STRONG>-1<\/STRONG>)); \/* 28 \ucd9c\ub825 *\/<BR>&nbsp; &nbsp; printf(&#8220;%d\\n&#8221;, sum_list(1,2,3,4,5,6,7,8,<STRONG>-1<\/STRONG>)); \/* 36 \ucd9c\ub825 *\/<BR>&nbsp; &nbsp; printf(&#8220;%d\\n&#8221;, sum_list(1,2,3,4,5,6,7,8,9,<STRONG>-1<\/STRONG>)); \/* 45 \ucd9c\ub825 *\/<BR>&nbsp; &nbsp; printf(&#8220;%d\\n&#8221;, sum_list(1,2,3,4,5,6,7,8,9,10,<STRONG>-1<\/STRONG>)); \/* 55 \ucd9c\ub825 *\/<BR><BR>&nbsp; &nbsp; return 0;<BR>}<\/DIV><br \/>\n<P><BR>\ub2e4\uc74c\uc740 &#8220;FreeBSD Library Functions Manual Man Page&#8221;\uc5d0 \uc81c\uc2dc\ub41c \ub610\ub2e4\ub978 \uc608\uc81c \ud504\ub85c\uadf8\ub7a8\uc774\ub2e4. \uc774 \uc608\uc81c\uc758 va_arg \ub9e4\ud06c\ub85c\ub97c \ubcf4\uba74 \uac00\ubcc0 \ud30c\ub77c\uba54\ud130\uc758 \ud0c0\uc785\uc774 \uc11c\ub85c \ub2e4\ub978 \uac83\ub3c4 \ucc98\ub9ac\ud560 \uc218 \uc788\uc74c\uc744 \uc54c \uc218 \uc788\ub2e4.<BR><\/P><br \/>\n<DIV>void foo(char *fmt, &#8230;)<BR>{<BR>&nbsp; &nbsp; <STRONG>va_list<\/STRONG> ap;<BR>&nbsp; &nbsp; int d;<BR>&nbsp; &nbsp; char c, *s;<BR><BR>&nbsp; &nbsp; <STRONG>va_start<\/STRONG>(ap, fmt);<BR>&nbsp; &nbsp; while (*fmt)<BR>&nbsp; &nbsp; &nbsp; &nbsp; switch(*fmt++) {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case &#8216;s&#8217;: \/* string *\/<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s = <STRONG>va_arg<\/STRONG>(ap, char *);<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&#8220;string %s\\n&#8221;, s);<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case &#8216;d&#8217;: \/* int *\/<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d = <STRONG>va_arg<\/STRONG>(ap, int);<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&#8220;int %d\\n&#8221;, d);<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case &#8216;c&#8217;: \/* char *\/<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/* Note: char is promoted to int. *\/<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c = <STRONG>va_arg<\/STRONG>(ap, int);<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&#8220;char %c\\n&#8221;, c);<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<BR>&nbsp; &nbsp; &nbsp; &nbsp; }<BR>&nbsp; &nbsp; <STRONG>va_end<\/STRONG>(ap);<BR>}<\/DIV><BR><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc21c\uc218 C\uc5b8\uc5b4 \ud568\uc218\ub294 \uc77c\ubc18\uc801\uc73c\ub85c \ud568\uc218 \ud30c\ub77c\uba54\ud130\uc758 \uac2f\uc218\uac00 \uace0\uc815\uc801\uc774\uace0 OOP\uc5d0\uc11c \ubcf4\uc774\ub294 \uc624\ubc84\ub85c\ub529\uacfc \uac19\uc774 \ud558\ub098\uc758 \ud568\uc218\uc774\ub984\uc73c\ub85c \uc11c\ub85c \ub2e4\ub978 \ud30c\ub77c\uba54\ud130\ub97c \uac00\uc9c0\ub294 \ud568\uc218\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc5c6\ub2e4. \uadf8\ub7f0\ub370 C\uc5b8\uc5b4 \ud568\uc218 \uc911 printf()\ub958\uc758 \ud568\uc218\ub294 \ud30c\ub77c\uba54\ud130\uac00 \ucd5c\uc18c 1 \uac1c \uc774\uc0c1\uc73c\ub85c \uac00\ubcc0\uc801\uc774\ub2e4. \uc608\ub97c \ub4e4\uba74 \uc544\ub798 printf \ud568\uc218\ub294 \ub3d9\uc77c\ud55c \uacb0\uacfc\ub97c \ucd9c\ub825\ud558\uc9c0\ub9cc \uc0ac\uc6a9\ud55c \ud30c\ub77c\uba54\ud130\uc758 \uac2f\uc218\ub294 \ub2e4\ub974\ub2e4. printf(&#8220;Hello World!&#8221;); \/* \ud30c\ub77c\uba54\ud130 1\uac1c \uc0ac\uc6a9 *\/ printf(&#8220;Hello %s!&#8221;,\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.happyfam.or.kr\/ysoh\/c%ec%96%b8%ec%96%b4%ec%97%90%ec%84%9c-%ea%b0%80%eb%b3%80-%ed%8c%8c%eb%9d%bc%eb%a9%94%ed%84%b0%eb%a5%bc-%ea%b0%80%ec%a7%80%eb%8a%94-%ed%95%a8%ec%88%98\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[246],"tags":[9,48,61],"class_list":["post-2871","post","type-post","status-publish","format-standard","hentry","category-c-c","tag-c","tag-stdarg-h","tag-61"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p776QY-Kj","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.happyfam.or.kr\/ysoh\/wp-json\/wp\/v2\/posts\/2871","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.happyfam.or.kr\/ysoh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.happyfam.or.kr\/ysoh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.happyfam.or.kr\/ysoh\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.happyfam.or.kr\/ysoh\/wp-json\/wp\/v2\/comments?post=2871"}],"version-history":[{"count":0,"href":"https:\/\/www.happyfam.or.kr\/ysoh\/wp-json\/wp\/v2\/posts\/2871\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.happyfam.or.kr\/ysoh\/wp-json\/wp\/v2\/media?parent=2871"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.happyfam.or.kr\/ysoh\/wp-json\/wp\/v2\/categories?post=2871"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.happyfam.or.kr\/ysoh\/wp-json\/wp\/v2\/tags?post=2871"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}