main.cpp

来自「C++ Source code from a tutorial」· C++ 代码 · 共 49 行

CPP
49
字号
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(int argc, char *argv[])
{
    signed char ch = '\n';
    ch = 128;

    cout << endl << "short int" << endl;    
    short int hoopla;
    hoopla = 0x0000;
    cout << "0x0000: " << hoopla << endl;
    hoopla = 0x0001;
    cout << "0x0001: " << hoopla << endl;
    hoopla = 0x7fff;
    cout << "0x7fff: " << hoopla << endl;
    hoopla = 0x8000;
    cout << "0x8000: " << hoopla << endl;
    hoopla = 0xffff;
    cout << "0xffff: " << hoopla << endl;
    
    cout << endl << "bool" << endl;
    bool b = true;
    cout << b << endl;
    b = false;
    cout << b << endl;
    cout << sizeof(b) << endl;
    
    cout << endl << "float" << endl;
    float f = 10.123;
    cout << f << endl;
    cout << sizeof(f) << endl;
    
    cout << endl << "double" << endl;
    double d = 10.234;
    cout << d << endl;
    cout << sizeof(d) << endl;
    
    cout << endl << "long double" << endl;
    long double ld = 1234567890.1234567890;
    cout << ld << endl;
    cout << sizeof(ld) << endl;

    system("PAUSE");	
    return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?