C - 关于Windows奇怪的行为 [英] C - on Windows Odd behavior

查看:64
本文介绍了C - 关于Windows奇怪的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我的C程序出现了一个奇怪的错误。它从VB包装程序创建的文本文件中接收参数。其中一个输入是作业名称。当为此作业名输入某些值时,代码会发生爆炸,而其他值则不会。此作业名用于创建目录。


当作业名具有LLLLLLL _ ### LL时,它会崩溃,其中L =字母,#=数字,_ =下划线。但是,如果只有2位数字& 3个数字后面有2个字母或1个字母,它可以正常工作。不幸的是,用户通常使用这种格式命名作业名称(例如:Bottle_400ml)。


有没有人见过这样的东西?


谢谢,

Sitko。

Hi,

I''m getting a weird error with my C program. It receives parameters from a text file that is created by a VB wrapper program. One of the inputs is a "jobname". The code bombs when certain values are inputed for this jobname, but not others. This jobname is used to create a directory.

It crashes when the jobname has LLLLLLL_###LL, where L = letters, and # = digits, and _ = underscore. But, if there are only 2 digits & 2 letters or 1 letter after the 3 digits it works fine. Unfortunately, the user typically names the job name with this format (ex: "Bottle_400ml").

Has anyone seen anything like this before?

Thanks,
Sitko.

推荐答案

发布读取作业名的代码。


奇怪的错误有点模糊。究竟是什么样的错误??
Post the code that reads the jobname.

"weird error" is a little vague. Exactly what kind of error??


弹出的错误是:

" D:\ Bottle_400mL

'' - ^''不被识别为内部或外部命令,

可操作程序或批处理文件。

文件名,目录名或卷标语法不正确。

(注意:^符号是一个向上箭头字符。)


起初而不是 - ^它说/拒绝不被认为是内部......


我认为导致错误的代码是:
The error that pops up is:
"D:\Bottle_400mL
''-^'' is not recognized as an internal or external command,
operable program or batch file.
The filename, directory name or volume label syntax is incorrect."
(note: the "^" symbol is an "up arrow" character.)

At first instead of "-^" it said "/Decline" is not recognized as an internal...

The code that I ''think'' cause the error was this:
展开 | 选择 | Wrap | 行号



if(strcmp(strType," Decline")== 0)

{

strcpy(sysCall," mkdir");

strcat(sysCall,gstrJobname);

system(sysCall);

}

if(strcmp(strType," Decline")== 0)

{

strcpy(sysCall," mkdir");

strcat(sysCall,gstrJobname);

strcat(sysCall,斜杠);

strcat(sysCall,strType);

system(sysCall);

}
if (strcmp(strType,"Decline")==0)
{
strcpy(sysCall,"mkdir ");
strcat(sysCall,gstrJobname);
system(sysCall);
}
if (strcmp(strType,"Decline")==0)
{
strcpy(sysCall, "mkdir ");
strcat(sysCall, gstrJobname);
strcat(sysCall, slash);
strcat(sysCall, strType);
system(sysCall);
}



再次告诉我这段代码是如何工作的。看起来strcmp在每种情况下都是正确的 - 并且yioiu有不同的内容。


另外,在Windows端,你的斜线必须是\\。

Tell me again how this code works. It looks like the strcmp is true in each case-and yioiu haver different contents.

Also, on the Windows side, your slash has to be \\.


这篇关于C - 关于Windows奇怪的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆