Read input.txt file and also output.bmp file from terminal (C-programming)

The full prototype for a standard main() is

int main(int argc, char* argv[]);

You get an int with the number of arguments, argc and
a list of “strings” (as far as they exist in C), argv.

You can for example use

#include "stdio.h"
int main(int argc, char* argv[])
{

    printf("Number: %d\n", argc);
    printf("0: %s\n", argv[0]);
    if (1<argc)
    {
        printf("1: %s\n", argv[1]);
    }
}

to start playing with the arguments.

Note that this is intentionally not implementing anything but a basic example of using command line parameters. This matches an accpeted StackOverflow policy of providing help with assignments, without going anywhere near solving them.

Leave a Comment