C++ 速查手冊 V1.00 - 單元 3 範例




u0301.cpp


#include <iostream> 

int main() {
    std::cout << "bool: " 
              << sizeof(bool) 
              << std::endl;    
     
    return 0;
}
 
/* Kaiching Chang
   u0301.cpp
   2014-02 */

u0302.cpp


#include <iostream> 

int main() {
    std::cout << "char: " 
              << sizeof(char) 
              << std::endl;    
    std::cout << "wchar_t: " 
              << sizeof(wchar_t) 
              << std::endl;
    std::cout << "char16_t: " 
              << sizeof(char16_t) 
              << std::endl;
    std::cout << "char32_t: " 
              << sizeof(char32_t) 
              << std::endl; 
   
    return 0;
}
 
/* Kaiching Chang
   u0302.cpp
   2014-02 */

u0303.cpp


#include <iostream>

int main() {
   std::cout << "short : "
             << sizeof(short) 
             << std::endl;
   std::cout << "short int : "
             << sizeof(short int)
             << std::endl;
   std::cout << "signed short : "
             << sizeof(signed short)
             << std::endl;
   std::cout << "signed short int : "
             << sizeof(signed short int)
             << std::endl;
   std::cout << "unsigned short : "
             << sizeof(unsigned short)
             << std::endl;
   std::cout << "unsigned short int : "
             << sizeof(unsigned short int)
             << std::endl;
   std::cout << "int : "
             << sizeof(int)
             << std::endl;
   std::cout << "signed : "
             << sizeof(signed)
             << std::endl;
   std::cout << "signed int : "
             << sizeof(signed int)
             << std::endl;
   std::cout << "unsigned : "
             << sizeof(unsigned)
             << std::endl;
   std::cout << "unsigned int : "
             << sizeof(unsigned int)
             << std::endl;
   std::cout << "long : "
             << sizeof(long)
             << std::endl;
   std::cout << "long int : "
             << sizeof(long int)
             << std::endl;
   std::cout << "signed long : "
             << sizeof(signed long)
             << std::endl;
   std::cout << "signed long int : "
             << sizeof(signed long int)
             << std::endl;
   std::cout << "unsigned long : "
             << sizeof(unsigned long)
             << std::endl;
   std::cout << "unsigned long int : "
             << sizeof(unsigned long int)
             << std::endl;
   std::cout << "long long : "
             << sizeof(long long)
             << std::endl;
   std::cout << "long long int : "
             << sizeof(long long int)
             << std::endl;
   std::cout << "signed long long : "
             << sizeof(signed long long)
             << std::endl;
   std::cout << "signed long long int: "
             << sizeof(signed long long int)
             << std::endl;
   std::cout << "unsigned long long : "
             << sizeof(unsigned long long)
             << std::endl;
   std::cout << "unsigned long long int: "
             << sizeof(unsigned long long int)
             << std::endl;

   return 0;
} 

/* Kaiching Chang
   u0303.cpp
   2014-02 */

u0304.cpp


#include <iostream>
 
int main() {
   std::cout << "float: " 
             << sizeof(float) 
             << std::endl;
   std::cout << "double: " 
             << sizeof(double) 
             << std::endl;
   std::cout << "long double: " 
             << sizeof(long double) 
             << std::endl;

    return 0;
}

/* Kaiching Chang
   u0304.cpp
   2014-02 */

the end

沒有留言: