1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
int main(int argc, const char *argv[])
{
    mintf("We are %d and we are %s.", 3, "joyous");
    // Step through.  When you see a %…, call va_arg(…) to get one argument
    // from the additional arguments.  The %… tells you the type and how to
    // format it.

    char*  s = va_arg(more_args, char*);   // "768336"
    int    n = va_arg(more_args, int);     // 768336   -OR-  'A'   -OR-    65
    double f = va_arg(more_args, double);  // 768.336
    // A double is just another kind of floating point value (e.g., 768.336).

    // Prof.  Lu:    char *s = "airplane";  // more traditional
    //               Type of s is "char *".  Variable name is "s"
    // Me:           char* s = "airplane";  // expresses that char* is a type
    //               Type of s is "char*".   Variable name is "s"

    return 0;
}

© Copyright 2016 Alexander J. Quinn         This content is protected and may not be shared, uploaded, or distributed.