简体   繁体   中英

Set variable not displayed on windows command prompt. (C++)

#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.
}

So I compiled the program into an executable and run the executable, there were no errors , however when the variable was to be called on the command prompt, the value of it isn't displayed and any string after it isn't displayed either. Anything before cout << Variable << endl; seems to display. If I were to write a simple "hello world" program(no variables whatsoever) it would run normally displaying every string in the correct order.

https://ideone.com/Ttkxeg

This is your code, with some more additions, and it works perfectly! Seems to me that your environment needs a return statement.

Try appending return 0; at the end of main() , else there is no error with the code!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM