可执行编译的C ++程序无法正常运行

时间:2015-10-18 17:30:29

标签: c++ windows cmd

#include <iostream>
#include <cstdlib>

using namespace std;

int main() {

    system("color 5");

    int Variable = 5;

    cout << " Value of variable: " << Variable << endl;
    cout << "  Value of variable x 2: " << Variable + Variable << endl;
    //Testing of string variables
    cout << endl;
    cout << "What is your name:" << flush;

    string input;
    cin >> input;

    cout << "Hello there, " << input << endl;
    //Testing of integer values below(Variable)
    cout << endl;
    cout << "Enter the value of X: " << flush;
    int value;
    cin >> value;

    cout << "The number you entered: " << value << endl;
    cout << endl;
    //----------------------------------------------------
    cout << "Memory size of X: " << sizeof(value) << " bytes" << endl;
    cout << " " << endl;
    //If statement demonstrated below
    if(value == 17) {
        cout << "Correct number selected" << endl;
    }
    if(value != 17) {
        cout << "Incorrect Number selected" << endl;
    }

    return 0;
}

由于某种原因,命令提示符不希望在第一个变量callout @ cout << " Value of variable: " << Variable << endl;之后显示任何内容,是否有人知道问题是什么? (这是我双击.exe文件或从cmd开始的时候)

当我在CodeBlocks上运行它时,它运行正常,没有任何问题。

0 个答案:

没有答案