ANSI C——¿É±ä²ÎÊý
¡¾ÔÐÍ¡¿
type fun( type arg1, type arg2, ...
);
¡¾ÃèÊö¡¿
Ö÷ÒªÓÃÔÚ²ÎÊý¸öÊý²»È·¶¨µÄº¯ÊýÖУ¬ÀýÈ磺printfº¯Êý¡£
¡¾Ê¹Ó÷½·¨¡¿
²Î¿¼£ºglib/manual/Add.c
#include <stdarg.h>
#include <stdio.h>
int add_em_up (int count,...)
{
va_list ap;
int i, sum;
va_start (ap, count); /* Initialize the argument list. */
sum = 0;
for (i = 0; i < count; i++)
sum += va_arg (ap, int); /* Get the next argument value. */
va_end (ap); /* Clean up. */
return sum;
}
int main (void)
{
/* This call prints 16. */
printf ("%d\n", add_em_up (3, 5, 5, 6));
/* This call prints 55. */
printf ("%d\n", add_em_up (10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
return 0;
}
ÔËÐнá¹û£º
16
55
¡¾ÊµÏÖ·ÖÎö¡¿
Èç¹ûҪʵÏֿɱä²ÎÊý£¬¹Ø¼üÊÇÎÒÃÇÔõÑù±éÀúº¯ÊýÁбí
£¬Õâ¾ÍÇ£³¶µ½º¯ÊýµÄ²ÎÊýÁ´±íÔÚÕ»ÖеĴæ·Å˳ÐòÎÊÌ⣺
º¯ÊýÈëÕ»µÄ¹ý³Ì´óÖÂÈçÏ£º (¸üÏêϸµÄÄÚÈݲο¼ÕâÀï
)
º¯ÊýµÄ¾Ö²¿±äÁ¿ÈëÕ»£»
ÆäËû±»µ÷º¯ÊýÐÅÏ¢Ö¸ÕëÈëÕ»£»
º¯Êý·µ»ØµØÖ·ÈëÕ»£»
²ÎÊýÁбíÈëÕ»£¬Ë³Ðò´ÓÓÒµ½×ó£»
´ËʱÎÒÃÇ¿ÉÒÔÃ÷È·²ÎÊýÁбíµÄ´æ·Å˳Ðò£¬ÈçÏ£º
ËùÒÔÎÒÃDZØÐëÒªÖªµÀÕ»¶¥²ÎÊýµØÖ·£¬¼´º¯ÊýµÄµÚÒ»¸ö²ÎÊý£»
Ö÷ÒªÒÀ¿¿¶¨ÒåÔÚstdarg.hÖÐÈý¸öºê£º
void va_start( va_list arg_ptr, prev_param ); /*¸ø³öµÚÒ»¸ö²ÎÊýµÄµØÖ·*/
type va_arg( va_list arg_ptr, type ); /*´ÓµÚ¶þ¸ö²ÎÊý¿ªÊ¼È¡£¬Ã¿´Î·µ»ØÒ»¸ö*/
void va_end( va_list arg_ptr ); /*±ê¼
Ïà¹ØÎĵµ£º
1. ¸ø¶¨µÈʽ A B C D E ÆäÖÐÿ¸ö×Öĸ´ú±íÒ»¸öÊý×Ö£¬ÇÒ²»Í¬Êý×Ö¶ÔÓ¦²»
D F G &nbs ......
¹ØÓÚº¯ÊýÖ¸ÕëÊý×éµÄ¶¨Òå
¹ØÓÚº¯ÊýÖ¸ÕëÊý×éµÄ¶¨Òå·½·¨£¬ÓÐÁ½ÖÖ£ºÒ»ÖÖÊDZê×¼µÄ·½·¨£»Ò»ÖÖÊÇÃÉÆ·¨¡£
µÚÒ»ÖÖ£¬±ê×¼·½·¨£º
{
·ÖÎö£ºº¯ÊýÖ¸ÕëÊý×éÊÇÒ»¸öÆäÔªËØÊǺ¯ÊýÖ¸ÕëµÄÊý×é¡£ÄÇôҲ¾ÍÊÇ˵£¬´ËÊý¾Ý½á¹¹ÊÇÊÇÒ»¸öÊý×飬ÇÒÆäÔªËØÊÇÒ»¸öÖ¸Ïòº¯ÊýÈë¿ÚµØÖ·µÄÖ¸Õë¡£
¸ù¾Ý·ÖÎö£ºÊ×ÏÈ˵Ã÷ÊÇÒ»¸öÊý×飺Êý×éÃû[]
Æä´Î£¬ÒªËµÃ ......
In C programming language, the observer design pattern is implemented with function pointer (aka callback function). But in Qt library, it introduces signal and slot. How to link a callback function from the C callback function to the C++ siganl and slot is a problem I encounter. Call back function ......
Reading and Writing Excel file with pure C api in windows system. tested on windows 2000, hope it can help you:
#ifndef _WINXLS_H_
#define _WINXLS_H_
/*============================================================================*
* Include Files
*================== ......