vs2013/2015/2008のデバッグでいくつかの問題が発生しました。VSデバッグモードのif ... elseの2つの分岐をこのコードが実行する理由
#include <iostream>
using namespace std;
int main()
{
int mode = 1;
int size = 1;
if (mode == 0)
{
cout << "mode = 0" << endl;
}
else
{
if (mode == 1)
{
if (size > 0)
{
cout << "mode=1,size=1" << endl; //in debug mode will execute this sentence
}
else
return 0; //however,when I Step in (F10),this will also be executed but have no influence.But When I insert a breakpoint in there and press F5, will not break in there
}
else if (mode == 2)
{
if (size > 0)
{
cout << "mode=2,size=1" << endl;
}
else
return 0;
}
}
return 1;}
だから、どのようにこの現象を説明するには?何か問題はありますか?そして私はそれをどのように解決できますか?
私はあなたが苦しんでいる問題が何であるか分かりません。もっと詳しく説明できますか? – Polyov
pic1とpic2が表示され、コードをステップバイステップで実行しようとします –
逆アセンブリウィンドウを使用して、実際に何が実行されているかを調べることができます:) – OMGtechy