简体   繁体   English

如何知道argv [0]和argv [1]之间是否有空格

[英]How to know if there is space between argv[0] to argv[1]

My program gets main parameters and my assignment is to check if the user has entered a space between the execution file to the parameters. 我的程序获取主要参数,我的任务是检查用户是否在执行文件与参数之间输入了空格。

  • This is an example for someone who hasn't entered space between the argv[0] being HW01 and argv[1] being /n : HW01/n 这是某人未在argv[0]HW01argv[1]/n之间输入空格的示例: HW01/n
  • But if someone types the line with a space between the file name and the parameters, I need to identify it: HW01 /n But the question is: How do I do it? 但是,如果有人在文件名和参数之间键入带空格的行,则需要识别它: HW01 /n但是问题是:我该怎么做?

I've checked if the space is added to the end of argv[0] or the the beginning of argv[1] but it wasn't there. 我检查了是否将空格添加到argv[0]的末尾或argv[1]的开头,但不存在。

I'm using Windows. 我正在使用Windows。

What you want to do is not use argv. 您要使用的不是argv。

Instead, use the function GetCommandLine and parse the result yourself. 而是使用功能GetCommandLine并自己解析结果。

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

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