2015-10-17 143 views
0
#include <iostream> 

using namespace std; 

int main() { 

    int Variable = 5; 

    cout << Variable << endl; //any string that is requested to be called out by the system below will not appear. 
} 

因此,我將程序編譯爲可執行文件並運行可執行文件,但沒有錯誤,但是當在命令提示符下調用該變量時,其值不會顯示,並且任何字符串之後它也不顯示。 cout << Variable << endl;之前的任何內容似乎都會顯示。如果我要編寫一個簡單的「hello world」程序(不管用什麼變量),它會正常運行,以正確的順序顯示每個字符串。設置變量不顯示在Windows命令提示符下。 (C++)

+0

似乎工作正常:https://ideone.com/Rb8KEg –

+0

什麼命令提示? –

回答

0

https://ideone.com/Ttkxeg

這是你的代碼,有一些補充,它完美的作品! 在我看來,您的環境需要return聲明。

嘗試在main()的末尾附加return 0;,否則代碼沒有錯誤!

相關問題