134

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?

1

6 Answers 6

227
  • 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.

Adding Command Line Arguments

Sign up to request clarification or add additional context in comments.

8 Comments

@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++ ?
@Ahmad - No. Just type the arguments in like you would on the command line. ie. separated by spaces.
Is there any way to enter them into the terminal if it's run as a terminal application?
@ChrisZhang I assume you mean a Console Application, and the answer is No.
@Andrew Cooper Can you tell me plz how to pass multiple arguments in VS
|
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)

2 Comments

Thankyou ! I picked the other guy's answer because he was the first one to answer !
@AlexHart Can you tell me plz how to pass multiple arguments in VS ?
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.

enter image description here

 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 } } 

Comments

2
  1. Right click on Project Name.
  2. Select Properties and click.
  3. Then, select Debugging and provide your enough argument into Command Arguments box.

Note:

  • Also, check Configuration type and Platform.

img

After that, Click Apply and OK.

Comments

1

For Visual Studio 2022 - for console application

  1. Right-click on Project, click Properties
  2. Expand Debug -> Click on General (option)
  3. Click on Open Debug Launch profiles UI
  4. Pass the parameter in value place.

screenshot from VS 2022

Comments

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.