-1

Using Linux, when running a C++ program that takes a .txt file as an argc. i.e.

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

I can simply compile it, then type ./a.out file.txt

When using windows, after compiling it, how do i then run it including the file.txt as the argc?

sepp2k
  • 363,768
  • 54
  • 674
  • 675
Nathan
  • 13
  • 2

3 Answers3

2

You do it this same way, only the name of the executable changes e.g., program_name.exe file.txt.

James Adkison
  • 9,412
  • 2
  • 29
  • 43
1

In Linux you would normally use ./a.out file.txt (the default in Linux is that the current directory is not searched for executables). In Windows' standard command interpreter you can just write a file.txt, assuming that you have named your program a.exe (Windows' command interpreter searches the current directory regardless of your PATH). Different compilers differ in how you name the executable file, but with g++ use -o a and with Visual C++ use /Fea.

One way to run the Windows command interpreter is Windows key+R, then type cmd in the Run-dialog that pops up.

Cheers and hth. - Alf
  • 142,714
  • 15
  • 209
  • 331
0
  1. Run "cmd"
  2. Change directory to the executable file exists with command "cd"
  3. Exactly do that you did in Linux.
Mr. Handy
  • 356
  • 2
  • 14