I am working on a C project and can not figure out how to pass command line arguments to my main function in Visual Studio 2010 Express Edition. I want to debug - how do these command line arguments work?
-
possible duplicate of Debugging with command-line parameters in Visual Studio.– In silicoSep 13, 2010 at 0:52
5 Answers
- Right click your project in Solution Explorer and select Properties from the menu
- Go to Configuration Properties -> Debugging
- Set the Command Arguments in the property list.
-
@Andrew Cooper and what if we have 2 argument ? do we need to seprate then with
;
, and we set the path in the normal way like we did in c++ ?– RocketSep 7, 2013 at 15:58 -
5@Ahmad - No. Just type the arguments in like you would on the command line. ie. separated by spaces. Sep 10, 2013 at 0:01
-
Is there any way to enter them into the terminal if it's run as a terminal application? Jan 16, 2014 at 5:35
-
@ChrisZhang I assume you mean a Console Application, and the answer is No. Jan 16, 2014 at 17:55
-
@Andrew Cooper Can you tell me plz how to pass multiple arguments in VS Feb 3, 2016 at 22:43
Under Project->Properties->Debug, you should see a box for Command line arguments (This is in C# 2010, but it should basically be the same place)
-
Thankyou ! I picked the other guy's answer because he was the first one to answer !– FahadSep 13, 2010 at 1:00
-
@AlexHart Can you tell me plz how to pass multiple arguments in VS ? Feb 3, 2016 at 22:43
Visual Studio 2015:
Project
=>
Your Application Properties
. Each argument can be separated using space. If you have a space in between for the same argument, put double quotes as shown in the example below.
static void Main(string[] args)
{
if(args == null || args.Length == 0)
{
Console.WriteLine("Please specify arguments!");
}
else
{
Console.WriteLine(args[0]); // First
Console.WriteLine(args[1]); // Second Argument
}
}
- Right click on Project Name.
- Select Properties and click.
- Then, select Debugging and provide your enough argument into Command Arguments box.
Note:
- Also, check Configuration type and Platform.
After that, Click Apply and OK.
Visual Studio e.g. 2019 In general be aware that the selected Platform (e.g. x64) in the configuration Dialog is the the same as the Platform You intend to debug with! (see picture for explanation)
Greetings mic enter image description here