Programming in Linux is used to using command line parameters, so I tried it when using vs2010.
Create a project and write the following program in C ++:
# Include <iostream> # include <fstream> using namespace STD; int main (INT argc, char * argv []) {ifstream fin (argv [1], IOS :: in); // open the file in input mode // ifstream fin; Fin. open (argv [1], IOS: In); ofstream fout (argv [2], IOS: Out | IOs: APP ); // output and append the file. // ofstream fout; fout. open (argv [2], IOS: Out | IOs: APP); int C; while (! Fin. EOF () // determines whether the end of the file is {c = fin. get (); // get the character fout. put (c); // write character} fin. close (); // close the file fout. close (); Return 0 ;}
To implement the use of the command line parameter argv [] in the program, you need to set the properties of the project.
Project-> properties-> debugging-> command parameters, enter a.txt B .txt
At the same time, to facilitate testing, set the working directory as the desktop.
Project-> properties-> debugging-> working directory, set to desktop
Compile and execute the program.
This applet Copies files. A.txt --> B .txt