From 1d943da0cf9154e7ce78ce867cdbb91531c5d78e Mon Sep 17 00:00:00 2001 From: Matthew Sotoudeh Date: Tue, 25 Jul 2023 14:58:33 -0700 Subject: initial dietc commit --- tests/va_start.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/va_start.c (limited to 'tests/va_start.c') diff --git a/tests/va_start.c b/tests/va_start.c new file mode 100644 index 0000000..8644950 --- /dev/null +++ b/tests/va_start.c @@ -0,0 +1,21 @@ +// https://en.cppreference.com/w/cpp/utility/variadic/va_start + +#include +#include + +int add_nums(int count, ...) +{ + int result = 0; + va_list args; + va_start(args, count); + for (int i = 0; i < count; ++i) { + result += va_arg(args, int); + } + va_end(args); + return result; +} + +int main() +{ + printf("%d\n", add_nums(4, 25, 25, 50, 50)); +} -- cgit v1.2.3