使用visual studio 2015给出命令行参数,显示第二个参数错误。代码是低于第二个参数在命令行参数中不起作用
// command line options
printf("Mandatory arguments to long options are mandatory for short options too.\n");
printf(" -i, --input=PATH set the path to the input image\n");
printf(" (*.jpg, *.png, etc.)\n");
printf(" -o, --output=PATH set the path to the output image\n");
printf(" (*.jpg, *.png, etc.)\n");
每当我给出输出路径它显示错误。 Invalid command line argument
。我的序列就像命令行参数中的E:\ 1.jpg D:\。
编辑:
解析代码
// parse command line arguments
arg = 2;
while(arg < argc)
{
//
if(0==strcmp("-u", argv[arg]) || 0==strcmp("--usepyr", argv[arg]))
{
usepyr = 1;
++arg;
}
else if(0==strcmp("-i", argv[arg]) || 0==strcmp("--input", argv[arg]))
{
if(arg+1 < argc)
{
//
sscanf(argv[arg+1], "%s", input);
arg = arg + 2;
}
else
{
printf("# missing argument after '%s'\n", argv[arg]);
return 1;
}
}
else if(0==strcmp("-o", argv[arg]) || 0==strcmp("--output", argv[arg]))
{
if(arg+1 < argc)
{
//
sscanf(argv[arg+1], "%s", output);
arg = arg + 2;
}
else
{
printf("# missing argument after '%s'\n", argv[arg]);
return 1;
}
}
试图运行,并从here
显示,说什么的命令选项是代码不会帮助任何人在这里帮助你解决问题。您应该发布解析命令行的代码。 – JJF
我不明白你的问题。你问我们为什么你的代码打印,你已经通过了无效的命令行参数?因为你应该知道最好的。或者你是否从命令行调用'cl.exe'并将它传递给一些JPG文件? – szczurcio
@szczurcio它只是D:\\不是路径,我改了它 – ARG