简体   繁体   English

应用程序接受以下形式的命令行参数:*参数但不包含形式参数*或*参数*

[英]Application accepts command line argument of the form : *argument but not of the form argument* or *argument*

For example if my program name is test.c 例如,如果我的程序名称是test.c

Then for the following run command the argc = 2 instead of 4 . 然后对于以下运行命令, argc = 2而不是4

$test abc pqr* *xyz*

Try to run: 尝试运行:

$ echo abc pqr* *xyz*

and you will understand why you don't get the argc value you were expecting 你会明白为什么你没有得到你期望的argc

It is probably because your shell / cmd.exe (no specifics are given!) use the * as file glob. 这可能是因为你的shell / cmd.exe(没有给出具体信息!)使用*作为文件glob。 If there are no files found that match the glob, the result will be empty. 如果找不到与glob匹配的文件,则结果为空。

Try calling you program like this: 试试这样的程序:

test abc 'pqr*' 'xyz'

refer to http://en.wikipedia.org/wiki/Glob_%28programming%29 for details about globbing, and your shell's manual for details about escaping globs. 有关globbing的详细信息,请参阅http://en.wikipedia.org/wiki/Glob_%28programming%29 ;有关转义globs的详细信息,请参阅shell的手册。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM