First, it is highly recommended to download a virtual machine and install Ubuntu, and buy "Hi-C language"
Sometimes see the main function of some programs with parameters, such as
int Main (int argc,char argv[])
It was not possible to understand what was behind the argument.
Until....
1#include <stdio.h>2 3 intMainintargcChar*argv[]) {4 if(argc>1){5printf"%s\n", argv[1]);6 }7 return 0;8}
And in the console input
1 gcc test.c-o test2 ./test helloworld!
The first line compiles test.c source code into an executable file test
The second behavior of the main function is to pass in two parameters, assigning the array pointer to the string argv, respectively
Argv[0]= "./test"
argv[1]= "helloworld!"
The ARGC stores the number of parameters, such as argc=2 in the program.
Visible use the console to pass in parameters to the main function.
You can also use the > symbol to redirect the location of the output of the standard output stream.
In general the default output location is our display, but with > can be more flexible. Or the program above?
In bash, enter:
./test helloworld! > output.txt
After the carriage return there is no hint that everything is working properly.
But find the folder where the program, you will find a output.txt file, the content is helloworld!
The same can be used < to redirect the standard input stream, very suitable for a lot of data processing work, you certainly do not want a line of manual knocking data in.
Console primary gameplay under UNIX-like systems