Fucntion在调试和单独运行.exe时返回值 [英] Fucntion return value in debugging and when running .exe alone

查看:87
本文介绍了Fucntion在调试和单独运行.exe时返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我有一个函数,它的返回值在调试模式下没问题但是当我单独运行.exe时,值似乎(msg值)随机。



我尝试过:



我的功能

Hi all
I have a function which its return value is okay in debugging mode but when I run .exe alone the value seems(msg value) random.

What I have tried:

My function

void recv(int &id, char * msg, int & len)
{
//full msg buffer and len
}

推荐答案

您应该查看正确的变量初始化(作为规则,您应该初始化所有变量)。虽然调试版本会在未初始化的变量中添加零,但在发布版本中,您会在其中找到垃圾。
You should look at proper variable initialization (as rule, you should initialize all of your variables). While debug builds put zeroes in uninitialized variables, in release build you find garbage inside them.


这篇关于Fucntion在调试和单独运行.exe时返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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