Visual Studio Community 2017 C++Start Without Debugging Not Working with Command Arguments


  • I am running Visual Studio Community 2017 version 15.9.3

    I made a new empty Console Project by clicking File->New->Project->Windows Desktop Wizard

    and then choosing "Console Application" and "Empty Project".

    I wrote a simple program

    #include <iostream>
    using namespace std;
    int main()
    	char a;
    	cin >> a;
    	cout << a;

    and pressed Ctrl+F5.

    I inputed 'e' and this is the output:

    C:\Peter\_CPP\hello\Debug\hello.exe (process 4808) exited with code 0.
    Press any key to close this window . . .

    I pressed a key and the program exited.

    Then I made a file called "h.txt" and went to Project->Properties->Configuration Properties->Debugging->Command Arguments

    and used "<h.txt" for Command Arguments.

    This time, when I pressed Ctrl+F5, a console appeared and immediately closed.

    How can I solve this problem?


    • Edited by Yeeter Thursday, December 6, 2018 2:22 PM
    Thursday, December 6, 2018 2:21 PM

All replies

  • Hi Yeeter,

    Welcome to the MSDN forum.

    If what you want is to add a .txt file to command arguments and use the data of it. I recommend you just type “test.txt” instead of “<test.txt”.

     Meanwhile, you can follow the following steps to get the data by command arguments.

    1. right click the project in solution explorer, choose add a new item, choose TextFile(.txt) and name it test.txt. Write some data in it like this: para1 para2 3 4 5 6 7 8 9...
    2. type “test.txt” instead of “<test.txt” in command arguments.
    3. write the code like below:

    #include <iostream>

    #include <string>

    #include <fstream>

    #include <sstream>

    using namespace std;

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

                  //get the data

                  fstream f;


                  string line;

                  getline(f, line);

                  cout <<"content is:"<< line << endl;

                  //use this way to get every item of the data

                  string str1, str2, str3;

                  std::istringstream is(line);

                  is >> str1 >> str2 >> str3;

                  cout << str1 << "," << str2 << "," << str3 << endl;

                  //prevent the window from disappearing


       return 0;


    In this way, you can use the data of txt file to satisfy your need.

    Best regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Monday, December 17, 2018 9:38 AM