
#include <stdio.h> int sum(int count, ...) { int total = 0; int * p = &count, i = 0; while(i < count) { total += *(++p); i++; } return total; } int main(void) { printf("%d\n", sum(10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); return 0; }这样就行了,第一个参数确定相加的个数,不然不知道什么时候相加结束。
[ 本帖最后由 lz1091914999 于 2011-5-25 16:54 编辑 ]

My life is brilliant