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?
Asked
Active
Viewed 1.9e+01k times
132

Jonathan Hall
- 75,165
- 16
- 143
- 189

Fahad
- 1,377
- 2
- 9
- 6
-
possible duplicate of [Debugging with command-line parameters in Visual Studio.](http://stackoverflow.com/questions/298708/debugging-with-command-line-parameters-in-visual-studio) – In silico Sep 13 '10 at 00:52
6 Answers
224
- 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.

Community
- 1
- 1

Andrew Cooper
- 32,176
- 5
- 81
- 116
-
@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++ ? – Rocket Sep 07 '13 at 15:58
-
6@Ahmad - No. Just type the arguments in like you would on the command line. ie. separated by spaces. – Andrew Cooper Sep 10 '13 at 00:01
-
Is there any way to enter them into the terminal if it's run as a terminal application? – Chris Zhang Jan 16 '14 at 05:35
-
@ChrisZhang I assume you mean a Console Application, and the answer is No. – Andrew Cooper Jan 16 '14 at 17:55
-
@Andrew Cooper Can you tell me plz how to pass multiple arguments in VS – The Beast Feb 03 '16 at 22:43
-
@Frankenstein - Just add them as you would on the command line, separated by spaces – Andrew Cooper Feb 05 '16 at 00:16
-
@AndrewCooper yes that what i have done but i'm unable to run it under VS however i can run it from command line : please view http://stackoverflow.com/questions/35196376/how-to-pass-multiple-commands-arguments-in-visual-studio – The Beast Feb 05 '16 at 00:29
-
@alex yes. It's free-form text. It should be able to take any argument string you'd have on the command line – Andrew Cooper Sep 14 '16 at 03:13
32
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)

Alex Hart
- 1,663
- 12
- 15
-
Thankyou ! I picked the other guy's answer because he was the first one to answer ! – Fahad Sep 13 '10 at 01:00
-
@AlexHart Can you tell me plz how to pass multiple arguments in VS ? – The Beast Feb 03 '16 at 22:43
13
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
}
}

Serge V.
- 3,377
- 3
- 20
- 28
0
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

mic
- 1
- 1
0
For Visual Studio 2022 - for console application
- Right-click on Project, click Properties
- Expand Debug -> Click on General (option)
- Click on Open Debug Launch profiles UI
- Pass the parameter in value place.

reach2saurabh
- 153
- 1
- 11