Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ C language to view various types of data size     - Ceph tuning --Journal and tcmalloc (Server)

- Git 2.5 increase in the working tree, triangle improved workflow performance (Linux)

- Use netcat [nc] command on Linux and Unix port scan (Server)

- Apple Mac computer to install Windows 10 Concise Guide (Linux)

- 256 with rich colors decorate your terminal (Linux)

- Oracle 11R2 Grid Infrastructure execute root.sh script rootcrs.pl execution failed treatment (Database)

- Oracle database on the hit rate of query summary (Database)

- CentOS 6.2 install git error Perl5 (Linux)

- To configure and use multiple Tomcat under Linux environment (Server)

- Do not find ifconfig eth0 and IP address under CentOS6.5 (Linux)

- Linux file and directory management - ls, cp, mv (Linux)

- Compile and install Memcached can not find GCC (Programming)

- CentOS7 Kubernetes used on container management (Server)

- Ubuntu install Scala 2.10.x version (Linux)

- Build your own Web server under Ubuntu Linux system (Server)

- Ubuntu 15.10 15.04 14.10 14.04 Install Ubuntu Tweak (Linux)

- How to choose the correct HTTP status code (Server)

- C # function (Programming)

- How to run Kali Linux 2.0 in Docker container (Linux)

- VMware virtual machine to install CentOS 7 (Linux)

 
         
  C language to view various types of data size
     
  Add Date : 2018-11-21      
         
         
         
  C language to view various types of data size

intptr_t definition /usr/include/stdint.h,

#if __WORDSIZE == 64

# Ifndef __intptr_t_defined
typedef long int intptr_t;
# Define __intptr_t_defined
# Endif
typedef unsigned long int uintptr_t;
#else
# Ifndef __intptr_t_defined
typedef int intptr_t;
# Define __intptr_t_defined
# Endif
typedef unsigned int uintptr_t;
#endif

 

#include

#include

int main (void)
{
    int * ptr;
    printf ( "sizeof int is% d \ n", sizeof (int));
    printf ( "sizeof char is% d \ n", sizeof (char));
    printf ( "sizeof short is% d \ n", sizeof (short));
    printf ( "sizeof long is% d \ n", sizeof (long));
    printf ( "sizeof float is% d \ n", sizeof (float));
    printf ( "sizeof double is% d \ n", sizeof (double));
    printf ( "sizeof pointer is% d \ n", sizeof (ptr));
    printf ( "sizeof unsiged int is% d \ n", sizeof (unsigned int));
    // Store pointers in integer type, use size_t, INT_PTR, intptr_t;
    printf ( "sizeof size_t is% d \ n", sizeof (size_t));
    // Intptr_t defines in stdint.h
    printf ( "sizeof intptr_t is% d \ n", sizeof (intptr_t));
    // INT_PTR only exist in windows
    // Printf ( "sizeof INT_PTR is% d \ n", sizeof (INT_PTR));
    
}

View MAX and MIN values for various data types

#include

#include
#include
int main ()
{
printf ( "The value of INT_MAX is% i \ n", INT_MAX);
printf ( "The value of INT_MIN is% i \ n", INT_MIN);
printf ( "An int takes% d bytes \ n", sizeof (int));

printf ( "The value of FLT_MAX is% f \ n", FLT_MAX);
printf ( "The value of FLT_MIN is% .50f \ n", FLT_MIN);
printf ( "A float takes% d bytes \ n", sizeof (float));

printf ( "The value of CHAR_MAX is% d \ n", CHAR_MAX);
printf ( "The value of CHAR_MIN is% d \ n", CHAR_MIN);
printf ( "A CHAR takes% d bytes \ n", sizeof (char));

printf ( "The value of DBL_MAX is% f \ n", DBL_MAX);
printf ( "The value of DBL_MIN is% .50f \ n", DBL_MIN);
printf ( "A double takes% d bytes \ n", sizeof (double));

printf ( "The value of SHRT_MAX is% d \ n", SHRT_MAX);
printf ( "The value of SHRT_MIN is% d \ n", SHRT_MIN);
printf ( "A short takes% d bytes \ n", sizeof (short));

printf ( "The value of LONG_MAX is% Ld \ n", LONG_MAX);
printf ( "The value of LONG_MIN is% Ld \ n", LONG_MIN);
printf ( "A long takes% d bytes \ n", sizeof (long));
return 0;
}

In stdint.h which defines many int * _t and uint * _t types.

#include

#include
#include

int main (int argc, char * argv [])
{
    printf ( "CHAR_BIT is% d \ n \ n", CHAR_BIT);
    printf ( "sizeof (char) is% d \ n", sizeof (char));
    printf ( "sizeof (short) is% d \ n", sizeof (short));
    printf ( "sizeof (int) is% d \ n", sizeof (int));
    printf ( "sizeof (long) is% d \ n", sizeof (long));
    printf ( "sizeof (long long) is% d \ n \ n", sizeof (long long));
    
    printf ( "sizeof (int8_t) is% d \ n", sizeof (int8_t));
    printf ( "sizeof (int16_t) is% d \ n", sizeof (int16_t));
    printf ( "sizeof (int32_t) is% d \ n", sizeof (int32_t));
    printf ( "sizeof (int64_t) is% d \ n \ n", sizeof (int64_t));

    printf ( "sizeof (uint8_t) is% d \ n", sizeof (uint8_t));
    printf ( "sizeof (uint16_t) is% d \ n", sizeof (uint16_t));
    printf ( "sizeof (uint32_t) is% d \ n", sizeof (uint32_t));
    printf ( "sizeof (uint64_t) is% d \ n", sizeof (uint64_t));
    
    char a, b;
    printf ( "sizeof (a + b) is% d \ n", sizeof (a + b));
    }
     
         
         
         
  More:      
 
- MySQL Authorized a recovered (Database)
- RocketMQ Message Queuing simple deployment (Linux)
- To teach you a trick to find the real IP address (Linux)
- Practical top command (Linux)
- Linux RHCS basic maintenance commands (Linux)
- How to test your MongoDB application upgrade? (Database)
- Java singleton mode (Singleton mode) (Programming)
- About Hibernate cache, you want the latest data have trouble even session.clear (Database)
- How to Install Foreman under Ubuntu (Server)
- How to use the DM-Crypt encryption Linux File System (Linux)
- Practical Handbook: 130+ improve the efficiency of commonly used commands Vim (Linux)
- Using Libreoffice under ubuntu (Linux)
- Build ftp server under CentOS 6.5 (Server)
- Ubuntu 12.04 kernel configuration automatically restart and crash dump (Linux)
- How to create an alternative Android / iOS connected wireless hotspot AP in Ubuntu 15.04 (Linux)
- Easily create RPM packages using the FPM (Linux)
- How to generate Linux, random password encryption or decryption (Linux)
- Perl loop (Programming)
- Safe learning through self-extracting package to achieve invasion (Linux)
- Node.js installed on Ubuntu Upstream version (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.