Per Erik Strandberg /cv /kurser /blog

A simple C template that compiles cleanly with gcc and prints the command line arguments. It resembles Csharp Console Template.

Download from here: [1]

#include <stdio.h>

int main(int argc, char * argv[])
{
    int i = 0;

    printf("hello world\n");

    while (i < argc)
    {
        printf("%d - %s\n", i, argv[i]);
        i++;
    }

    return 0;
}

Once we run it from the console it can look like this:

C:\tmp>hw.exe foo bar baz "x y z"
hello world
0 - hw
1 - foo
2 - bar
3 - baz
4 - x y z


Tillhör Kategori Mallar