specify.cpp

来自「Thinking in C++ 2nd edition source code 」· C++ 代码 · 共 38 行

CPP
38
字号
//: C03:Specify.cpp
// From Thinking in C++, 2nd Edition
// at http://www.BruceEckel.com
// (c) Bruce Eckel 1999
// Copyright notice in Copyright.txt
// Demonstrates the use of specifiers
#include <iostream>
using namespace std;

int main() {
  char c;
  unsigned char cu;
  int i;
  unsigned int iu;
  short int is;
  short iis; // Same as short int
  unsigned short int isu;
  unsigned short iisu;
  long int il;
  long iil;  // Same as long int
  unsigned long int ilu;
  unsigned long iilu;
  float f;
  double d;
  long double ld;
  cout << "sizeof(char) = " << sizeof(c) << endl;
  cout << "sizeof(unsigned char) = " << sizeof(cu) << endl;
  cout << "sizeof(int) = " << sizeof(i) << endl;
  cout << "sizeof(unsigned int) = " << sizeof(iu) << endl;
  cout << "sizeof(short) = " << sizeof(is) << endl;
  cout << "sizeof(unsigned short) = " << sizeof(isu) << endl;
  cout << "sizeof(long) = " << sizeof(il) << endl;
  cout << "sizeof(unsigned long) = " << sizeof(ilu) << endl;
  cout << "sizeof(float) = " << sizeof(f) << endl;
  cout << "sizeof(double) = " << sizeof(d) << endl;
  cout << "sizeof(long double) = " << sizeof(ld) << endl;
} ///:~

⌨️ 快捷键说明

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