Skip to content
Toward Polymath
Go back

[C] Data Type 자료형

Data type means the type of variables. Variables refer to an object to transfer or store a value as the code proceeds. In particular, since C is a programming language that can access memory addresses, it is important to set an appropriate type according to the type of data for efficient coding. Data types mainly used in C language are as follows.

Data TypeVolume(B)Min ValueMax Value
char10127
signed char1-128127
unsigned char10255
signed short2-3276832767
unsigned short2065535
(signed) int4-21474836482147483647
unsigned int404294967295
signed long4-21474836482147483647
unsigned long404294967295
signed long long8-92233720368547758089223372036854775808
unsigned long long8018499744073709551615
Data TypeVolume(B)Min ValueMax Value
float43.4e-373.4e+38
double81.7e-3073.4e+308

The real data cannot be used in octal or hexadecimal format, and only decimal representation is allowed. Also, the real data is signed without the concept of unsigned. The basic type of integer is signed int, the basic type of character is char, and the basic type of real is double. I/O format specifier without a predetermined data type is recognized as a default data type. The corresponding format specifiers are as follows.

Format SpecifierData Type
%dint, short
%ldlong
%lldlong long int
%uunsigned int
%ffloat
%lflong double, double
%cchar
%sstring
%ppointer

The last %p is a format specifier to the address of the variable. Also, the %s format specifier means a string.
In the code below, int i=427 means that the type of i is defined as int, and an integer 427 is assigned to this variable. Since the integer data type was used, the i variable allocates and uses the 4B memory area.

    #include <stdio.h>

    int main(void){
        int i=427;
        double a=427.427427427427;

        printf("%d\n", i);
        printf("%f\n", a);
        printf("%lf\n", a);


        return 0;
    }   
427
427.427427
427.427427

Share this post:

Previous Post
[C] Numeral System
Next Post
[C] 자료형