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

前端 未结 1 1445
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 12:57

I have to do an assignment where I have to write a C-Programm, where it gets the input-file-name from the console as command line parameter.
It should move the data from

相关标签:
1条回答
  • 2020-11-29 13:23

    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.

    0 讨论(0)
提交回复
热议问题