I am currently working on a C project and could 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?
我目前正在做一个C项目,不知道如何将命令行参数传递给Visual Studio 2010 Express Edition的主函数。我想调试——这些命令行参数是如何工作的?
4 个解决方案
#1
210
- Right click your project in Solution Explorer and select Properties from the menu
- 在解决方案资源管理器中右键单击项目,并从菜单中选择Properties
- Go to Configuration Properties -> Debugging
- 转到配置属性—>调试
- Set the Command Arguments in the property list.
- 在属性列表中设置命令参数。
#2
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)
在Project->Properties->Debug下,您应该会看到一个用于命令行参数的框(这在c# 2010中,但基本上应该是相同的位置)
#3
10
Visual Studio 2015:
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
}
}
#4
0
- Right click on Project Name.
- 右键单击项目名称。
- Select Properties and click.
- 选择,然后单击属性。
- Then, select Debugging and provide your enough argument into Command Arguments box.
- 然后,选择debug并在命令参数框中提供足够的参数。
Note:
注意:
- Also, check Configuration type and Platform.
- 另外,检查配置类型和平台。
After that, Click Apply and OK.
然后单击Apply和OK。
#1
210
- Right click your project in Solution Explorer and select Properties from the menu
- 在解决方案资源管理器中右键单击项目,并从菜单中选择Properties
- Go to Configuration Properties -> Debugging
- 转到配置属性—>调试
- Set the Command Arguments in the property list.
- 在属性列表中设置命令参数。
#2
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)
在Project->Properties->Debug下,您应该会看到一个用于命令行参数的框(这在c# 2010中,但基本上应该是相同的位置)
#3
10
Visual Studio 2015:
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
}
}
#4
0
- Right click on Project Name.
- 右键单击项目名称。
- Select Properties and click.
- 选择,然后单击属性。
- Then, select Debugging and provide your enough argument into Command Arguments box.
- 然后,选择debug并在命令参数框中提供足够的参数。
Note:
注意:
- Also, check Configuration type and Platform.
- 另外,检查配置类型和平台。
After that, Click Apply and OK.
然后单击Apply和OK。