tests/testargv.c
author Ryan C. Gordon <icculus@icculus.org>
Thu, 07 Jun 2018 23:48:39 -0400
changeset 123 3cd5b72c7f8e
parent 121 9c13e279cf87
permissions -rwxr-xr-x
Bunch more work on 16-bit entry points.

Can run testargv16.exe now. This means Watcom C startup code, and Watcom's
printf(), both work.
#include <stdio.h>

extern char **environ;

int main(int argc, char **argv) {
    int i;
    char **envp = environ;

    printf("Command line: (argc == %d)\n", argc);
    for (i = 0; i <= argc; i++) {
        printf("argv[%d] = '%s'\n", i, argv[i] ? argv[i] : "(null)");
    } // for

    printf("\nEnvironment:\n");
    for (i = 0; envp[i]; i++) {
        printf("envp[%d] = '%s'\n", i, envp[i] ? envp[i] : "(null)");
    } // for

    return 0;
} // main

// end of testargv.c ...