File: function7.c

package info (click to toggle)
chibicc 1.0.23.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,832 kB
  • sloc: ansic: 62,911; sh: 275; makefile: 92
file content (28 lines) | stat: -rw-r--r-- 484 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
#include <stdarg.h>
#include "test.h"

long double add_int_ld_variadic(int count, ...) {
    va_list ap;
    va_start(ap, count);

    int a = va_arg(ap, int);
    long double b = va_arg(ap, long double);

    va_end(ap);

    return a + b;
}

int main() {
    int x = 100;
    long double y = 10.5;

    long double result = add_int_ld_variadic(2, x, y);

    printf("Result = %.2Lf\n", result);
    ASSERT(110.5, result);
    // Expected: 110.50

    return 0;
}