复制字符串 [英] copy the string

查看:84
本文介绍了复制字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好


我在复制字符串时遇到了垃圾值问题如下 -


char strTemp [150] = " ;;

if(cls.GetVerifySucValue()== 0)

strcpy(strTemp," #No吸气阀或排气阀与您的Pre-匹配选择选项);


(实际上这是在intemmedite DLL中,所以我无法调试它)


提前谢谢

Meenal

Hi all

I am facing the problem of grabage value while copying the string as follows-

char strTemp[150]="";
if (cls.GetVerifySucValue()==0)
strcpy(strTemp,"#No Suction or Discharge valves were found matching your Pre-Selection options");

(Actually this is in the intemmedite DLL so that i can not debug it)

Thanks in advance
Meenal

推荐答案


大家好


我在复制字符串时遇到了草药值的问题如下 -


char strTemp [150] ="" ;;

if(cls。 GetVerifySucValue()== 0)

strcpy(strTemp,#No吸油阀或卸料阀与您的预选配件相匹配);


(实际上这是在intemmedite DLL中,所以我无法调试它)


提前谢谢

Meenal
Hi all

I am facing the problem of grabage value while copying the string as follows-

char strTemp[150]="";
if (cls.GetVerifySucValue()==0)
strcpy(strTemp,"#No Suction or Discharge valves were found matching your Pre-Selection options");

(Actually this is in the intemmedite DLL so that i can not debug it)

Thanks in advance
Meenal



这不是work.char strTemp [150] ="",它不正确。相当使用

char strTemp [150];

然后strTemp [0] =''\'''其中''\ 0''是终止字符串的空终止字符,这意味着现在这个字符串是空的并且准备正确地将数据复制到它中


Savage。

This is not going to work.char strTemp[150]="",it is not correct.Instead use

char strTemp[150];
and then strTemp[0]=''\0'' where ''\0'' is null terminating character which terminate the string,this means that now this string is empty and ready to copy data into it correctly

Savage.



这不是work.char strTemp [150] ="",它不正确。相当使用


char strTemp [150];

然后strTemp [0] =''\''''其中''\0''是终止字符串的空终止字符,这意味着现在这个字符串是空的并准备将数据复制到其中正确


Savage。
This is not going to work.char strTemp[150]="",it is not correct.Instead use

char strTemp[150];
and then strTemp[0]=''\0'' where ''\0'' is null terminating character which terminate the string,this means that now this string is empty and ready to copy data into it correctly

Savage.



很抱歉不同意Savage,但这样做是有效的。


代码没有任何问题。垃圾值来自其他地方。如果正在返回strTemp,那可能就是问题,因为strTemp位于堆栈上并且在从调用返回后是不确定的。


如果没有返回strTemp,那么你将必须提供更多信息来帮助您调试问题。


Adrian

Sorry to disagree Savage, but it is valid to do that.

The code has nothing wrong with it. The garbage value is coming from somewhere else. If strTemp is being returned, that would probably be the problem as strTemp is located on the stack and is indeterminate after returning from the call.

If strTemp is not being returned, then you will have to provide more information to help you debug the problem.


Adrian



很抱歉不同意Savage,但这样做是有效的。


代码没有任何问题。垃圾值来自其他地方。如果正在返回strTemp,那可能就是问题,因为strTemp位于堆栈上并且在从调用返回后是不确定的。


如果没有返回strTemp,那么你将必须提供更多信息来帮助您调试问题。


Adrian
Sorry to disagree Savage, but it is valid to do that.

The code has nothing wrong with it. The garbage value is coming from somewhere else. If strTemp is being returned, that would probably be the problem as strTemp is located on the stack and is indeterminate after returning from the call.

If strTemp is not being returned, then you will have to provide more information to help you debug the problem.


Adrian



你是对的。问题不在那个部分而且代码是正确的。我犯了一个很大的愚蠢错误。 :(


谢谢,纠正!


Savage

U are right.The problem is not in that part and the code is correct.I made a big stupid error. :(

Thanks,for correction!

Savage


这篇关于复制字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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