Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the basic data type of C language?

Shulou Source: shulou.com Published: 2022-06-02 07:19:29 09月24日 Update

This article mainly explains "what is the basic data type of C language". The content of the explanation in this article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought. Let's study and learn what the basic data types of C language are.

1. Data types contained in C language

As shown in the following figure:

2. Basic data types of C language

The six keywords short, int, long, char, float and double represent the six basic data types in the C language.

When formatting the output:

Int d

Short d

Long ld

Float f

Double lf

Char c

% x hexadecimal

% o Octal

% s string

% p generally outputs the value of the pointer as a hexadecimal integer with the prefix 0x

The memory size cut out by short on a 32-bit system is 2 byte

The memory size cut out by int is 4 byte.

The memory size cut out by long is 4 byte.

The memory size cut out by float is 4 byte.

The memory size cut out by double is 8 byte.

The memory size cut out by char is 1 byte.

(note: this refers to the general situation. Different platforms may be different. Specific platforms can be tested with the sizeof keyword.)

3. Sample code

/ / introduce the header file # include # include void main () {int i; printf ("Please enter an integer"); scanf ("% d", & I); printf ("% d\ n", I); float f = 10.01; printf ("% f\ n", f) / find the number of bytes occupied by a type, specifically related to the operating system printf ("bytes of int type% d\ n", sizeof (int)); printf ("bytes of float type% d\ n", sizeof (float)); printf ("number of bytes of double type% d\ n", sizeof (double)) / / the standard way to write a loop. Loop variables need to be extracted, otherwise int n = 0; for (; n) is compiled under GCC in Linux environment.

Tags: Type data language memory size byte loop variable learning input different lower editor key keyword content writing function hexadecimal can be passed through the platform Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Apple Microsoft macOS NVidia