2.1 变量名
      (1) 大小写敏感,小写一般做变量,大写做符号常量(symbolic constant)
      (2) 以字母和_开头,有些类库用了"_"

 2.2 数据类型和长度
    (1) char       //一般一个字节,8位
          unsigned char  (0~255)        signed char (-128~127) 
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main(int argc, char** argv) {
      printf("char_bit = %d\n", CHAR_BIT);
      printf("char_min = %d, char_max = %d\n", CHAR_MIN, CHAR_MAX);
      printf("signed_char_min = %d, signed_char_max = %d\n", SCHAR_MIN, SCHAR_MAX);
      printf("unsigned_char_min = %d, unsigned_char_max = %d\n", 0, UCHAR_MAX);
      return (EXIT_SUCCESS);
}
    (2) int
          short  (int 16 bits) <= int <= long (int  32 bits)
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main(int argc, char** argv) {
        printf("short_min = %d, short_max = %d\n", SHRT_MIN, SHRT_MAX);
        printf("int_min = %d, int_max = %d\n", INT_MIN, INT_MAX);
        printf("long_min = %d, long_max = %d\n", LONG_MIN, LONG_MAX);
        return (EXIT_SUCCESS);
}
        缺省情况下是signed, 如unsigned short (0~65535)   signed short (-32768 ~ 32767)
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main(int argc, char** argv) {
        printf("unsigned_short_max = %u\n", USHRT_MAX);
        printf("unsigned_int_max = %u\n", UINT_MAX);
        printf("unsigned_long_max = %u\n", ULONG_MAX); //注意%ud,u表示unsigned
        return (EXIT_SUCCESS);
}
    (3)  float (single-precision floating point), double, long double
          IEEE-754 
          float (4 bytes) or double (8 bytes)
          seeeeeeeemmmmmmmmmmmmmmmmmmmmmmm
          s = sign bit, e = exponent, m = mantissa
          N = mantissa * (2 ^  x),  x 是指数
#include <stdio.h>
#include <stdlib.h>
#include <float.h>

int main(int argc, char** argv) {
      printf("float: decimal digits of precision: %d\n", FLT_DIG);
      printf("float: number of base FLT_RADIX digits in mantissa: %d\n", FLT_MANT_DIG);
      printf("float: min_float = %e, max_float = %e\n", FLT_MIN, FLT_MAX);
      printf("======================================\n");
      printf("double: decimal digits of precision: %d\n", DBL_DIG);
      printf("double: number of base FLT_RADIX digits in mantissa: %d\n", DBL_MANT_DIG);
      printf("double: min_double = %e, max_double = %e\n", DBL_MIN, DBL_MAX);
      return (EXIT_SUCCESS);
}
       (4)  长度范围等可查看头文件 <limits.h> <float.h>中,依赖于不同的机器

2.3 常量
(1) 一般常量
int: 1234,31 = 037 = 0x1f = 0X1F //八进制 或者 16进制
long: 123456789L    usigned long: 123456789UL
double: 123.4, 1e-2,  当末尾加f或者F时,表明是float
(2) 字符常量
'0' == 48
'\0' == 0
'\ooo'  //八进制   #define VTAB '\013'    //#define  BELL  '\007'
'\xhh'  //16进制    #define VTAB '\xb'      //#define BELL '\x7'
 
\a  alert (bell)
\b  backspace
\f   formfeed
\n  newline
\r   carriage return
\t   horizontal tab
\v  vertical tab
\\   backslash
\?   question mark
\'    single quote
\"   double quote
(3) 表达式常量
#define MAXLINE 1000
char line[MAXLINE + 1];
 
#define LEAP 1  //leap year 闰年
int days[31+28+LEAP+31+30+31+30+31+31+30+31+30+31];
(4) 字符串常量
"I am a string" //字符串实质上是字符数组,以'\0'结尾
""   //空字符串 
" " //空格 字符串 
 
区分 'x' 和 "x"
'x' 是字符,本质上整型
"x"是字符串,以'\0'结尾
 
<string.h> 中 strlen(s) 求字符串的长度,不包括'\0'
(5) enumeration constant
enum boolean {NO, YES};  //第一个为0, 下一个为1, 依次增长
enum escapes {BELL = '\a', BACKSPACE = '\b', TAB = '\t',
                            NEWLINE = '\n', VTAB = '\v', RETURN = '\r'};
enum months {JAN = 1, FEB, MAR, APR, MAY, JUN,
                           JUL, AUG, SEP, OCT, NOV, DEC}; //从1开始增长

2.4 变量声明与初始化
(1)   变量声明
所有变量在使用之前必须先声明
char c, line[100]; 
char c;
char line[100];
(2)   变量初始化
float eps = 1.0e-5;
 
const double e = 2.71828182845905;
const char msg[] = "hello world!"; // const 表明该数组内的字符不可改
 
int strlen(const char[]);

2.5 数学运算符
+   -   *   /    %
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
                printf("%d is a leap year \n", year);
        else printf("%d is not a leap year \n", year);

2.6 关系运算符和逻辑运算符
(1) 关系运算符
      >    >=    <    <=
      ==    !=
      关系运算符的优先级 低于 数序运算符,即  i < lim -1  等同于 i < (lim -1)
 
(2) 逻辑运算符 &&  ||  !
       从左到右,evaluation stops as soon as the truth or false of the result is known.
      for( i = 0; i < lim -1 && (c = getchar()) != '\n'  && c != EOF; ++i )
             s[i] = c;
       逻辑表达式 真为1,假为0
       !取反