$ ls ~yifei/notes/

C 语言中的 vargs

Posted on:

Last modified:

int max(int n, ...) {
    va_list arg_pointer;
    int result = INT_MIN;

    va_start(arg_pointer, n);
    for (int i = 0; i < n; i++) {
        int arg = va_arg(arg_pointer, int);
        if (arg > result)
            result = arg;
    }
    va_end(arg_pointer);

    return result;
}

参考

  1. http://www.cnblogs.com/chinazhangjie/archive/2012/08/18/2645475.html

  2. http://wiki.jikexueyuan.com/project/c-advance/other.html

WeChat Qr Code

© 2016-2022 Yifei Kong. Powered by ynotes

All contents are under the CC-BY-NC-SA license, if not otherwise specified.

Opinions expressed here are solely my own and do not express the views or opinions of my employer.

友情链接: MySQL 教程站