void SetMeasurementParameter(unsigned int SampleCount, unsigned int SampleInteval,...) { printf("%d %d\r\n", SampleCount, SampleInteval);}void SetMeasurementParameter2(int co.">
赞
踩
- #include "stdio.h"
- #include <stdarg.h>
-
- void SetMeasurementParameter(unsigned int SampleCount,
- unsigned int SampleInteval,...)
- {
- printf("%d %d\r\n", SampleCount, SampleInteval);
- }
-
- void SetMeasurementParameter2(int count, va_list ap) {
- unsigned int SampleCount;
- unsigned int SampleInteval;
-
- //int t = count;
-
- //while (t != -1) {
- // printf("%d\r\n", t);
- // t = va_arg(ap, int); //将当前参数转换为int类型
- //}
-
- SampleCount = va_arg(ap, int);
- SampleInteval = va_arg(ap, int);
- }
-
- typedef void (*SYNC_FUNC)(int count, va_list va);
-
- void RunSyncFunc(unsigned int SynID, SYNC_FUNC func, int count, ...) {
- va_list ap;
- int t = count;
-
- va_start(ap, count);
- func(count, ap);
-
- /* while (t != -1) {
- printf("%d\r\n", t);
- t = va_arg(ap, int); //将当前参数转换为int类型
- }
- */
- va_end(ap);
- }
-
- void main(void) {
- printf("hello world");
- RunSyncFunc(0, SetMeasurementParameter2, 2, 11,12, -1);
- }
-
- int Sum(int first, int second, ...) {
- int sum = 0, t = first;
- va_list vl;
- va_start(vl, first);
- while (t != -1) {
- sum += t;
- t = va_arg(vl, int); //将当前参数转换为int类型
- }
- va_end(vl);
- return sum;
- }
-
- /*
- int main(int argc, char* argv[]) {
- printf("The sum is %d\n", Sum(30, 20, 10, -1)); //-1是参数结束标志
- return 0;
- }*/
-
- void TestFun(char* pszDest, int DestLen, const char* pszFormat, ...) {
- va_list args;
- va_start(args, pszFormat);
- //_vsnprintf(pszDest, DestLen, pszFormat, args);
- va_end(args);
- }
-

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。