linux c 笔记-3 c语言基础知识

关键字

数据类型:
  简单(7):int long short float double char enum

  复杂(2):struct union

  类型修饰符(8):auto unsigned signed extern register static volatile void

  定义(2): typedef const
  其他(1): sizeof

   

      数据类型示意图:

    

  

流程控制:
  条件跳转(5):

    if else
    switch case default
  循环(5):
    do while
    for
    continue
    break

  无条件跳转(2):
    goto
    return

运算符

  加减乘除:+          -           *            /

  模: %

  移位: >>             <<

      比较: >            <            =         != 

  自增/减: ++  --

数据类型详解

  整型: short  int long (char)

     32bit机器上

类型字节值范围
char -128 ~ 127(有符) 或 0 ~ 255 (无符)
unsigned char 0 ~ 255
signed char -128 ~ 127
int 2 或 4  -3 2768 ~ 3 2767 或 -21 4748 3648 ~ 21 4748 3647
unsigned int 2 或 4  0 ~ 6 5535 或 0 ~ 42 9496 7295
short -3 2768 ~ 3 2767
unsigned short 0 ~ 6 5535
long -21 4748 3648 to 21 4748 3647
unsigned long 0 ~ 42 9496 7295

  

    int占用的具体字节数,不同机器环境不同,具体用sizeof查看:

#include<stdio.h>
void main()
{
        printf("sizeof inf:%d
", sizeof(int));
}

    浮点型:

类型字节范围精度
float 1.2E-38 ~ 3.4E+38 6 decimal places
double 2.3E-308 ~ 1.7E+308 15 decimal places
long double 10  3.4E-4932 ~ 1.1E+4932 19 decimal places

  

 

参考:http://www.tutorialspoint.com/cprogramming/c_quick_guide.htm

原文地址:https://www.cnblogs.com/Tommy-Yu/p/5818717.html