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
29
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>

int main(int argc, char* argv[]) {
    // 0 argument varardic function call
    printf("Hello World\n");
    // 1 argument call
    printf("Hello %s\n", "David");
    // 1 argument call - wrong type, printf has no way to know we passed the wrong type
    // gcc is pretty smart and will catch *printf* wrong argument types
    // gcc will *not* catch wrong argument types for mintf
    // this is not something you are expected to test in HW04, this is unspecified behavior
    //printf("Hello %d\n", "David");
    //printf("Hello %s\n", 123);

    // 2 argument call, with different types
    printf("Hello %s, today is the %dth of June\n", "David", 6);

    // these are also broken calls to the function
    // not something you are expected to test
    // too many arguments? ignored
    printf("Hello World\n", "David");
    // too few arguments? random garbage
    printf("Hello %s\n");
    return EXIT_SUCCESS;
}
/* vim: set tabstop=4 shiftwidth=4 fileencoding=utf-8 noexpandtab: */

© Copyright 2024 Alexander J. Quinn & David Burnett         This content is protected and may not be shared, uploaded, or distributed.