• Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Print View
    • Edit
    • Load
  • Login

Navigation

  • RecentChanges
  • FindPage
  • HelpContents
  • index

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment

BookWiki:
  • The_C_Programming_Language

Relative Links: C Programming Language

The C Programming Language

Contents

  1. The C Programming Language
    1. 图书信息
    2. Contents
      1. Chapter 1 - A Tutorial Introduction
      2. Chapter 2 - Types, Operators and Expressions
        1. 2.1 Variable Names
        2. 2.2 Data Types and Sizes
          1. 整数
          2. 浮点数
          3. 字符
          4. 逻辑类型
        3. 2.3 Constants
        4. 2.6 Relational and Logical Operators
        5. 2.7 Type Conversions
        6. 2.11 Conditional Expressions
        7. 2.12 Precedence and Order of Evaluation
      3. Chapter 3 - Control Flow
        1. 3.4 Switch
        2. 3.5 Loops - While and For
        3. 3.7 Break and Continue
        4. 3.8 Goto and labels
      4. Chapter 4 - Functions and Program Structure
      5. Chapter 5 - Pointers and Arrays
      6. Chapter 6 - Structures
      7. Chapter 7 - Input and Output
      8. Chapter 8 - The UNIX System Interface
    3. The book

这是一本programmer写给programmer看的书

图书信息

surface.jpg http://book.douban.com/subject/1236999/

  • 作者: Brian W. Kernighan / Dennis M. Ritchie
  • 出版社: Prentice Hall
  • 副标题: Second Edition
  • 出版年: 1989-03-01
  • 页数: 274
  • 定价: $48.67
  • 装帧: Paperback
  • ISBN: 9780131103627

Contents

attachment:book.png

Chapter 1 - A Tutorial Introduction

Chapter 2 - Types, Operators and Expressions

2.1 Variable Names

2.2 Data Types and Sizes

c语言的类型(斜体是C99的类型)

  • 整数: char/short/int/long/long long

  • 浮点数:float/double/long double

  • 逻辑:bool

  • 指针
  • 自定义类型

int/long/double

  • 格式: %d/%ld/%lf
  • 范围:char<short<int<float<double

  • 长度:1byte ~ 16 byte
  • 内存中的形式: 二进制数(补码)、编码

整数
  • char: 1 byte(8 bit): -128~127
  • short: 2 bytes: -32768~32767
  • int: depend on compiler(cpu), usually 1 byte: %d
  • long: same as above:
  • long long: 8 byte: %ld
  • unsigned: 后面加u或U: %u
  • unsigned long long: %lu
  • 16进制和8进制

浮点数

类型

字⻓

范围

有效数字

scanf

printf

float

32

±(1.20E38

7

%f

%f, %e

double

64

±(2.2E308

15

%lf

%f, %e

  • 带小数点的字面量是double而不是float;
  • float需要用f或F为后缀来表明身份;
  • 如果没有特殊需要,只使用double;对于现代cpu,存储和计算double与float是一样的;

字符
  • char是一种整数,也是一种特殊的类型:字符
  • scanf和printf用%c来输入输出字符

逻辑类型

#include "stdbool.h" 之后就可以使用bool和true、false了

2.3 Constants

int/float/char/enum

2.6 Relational and Logical Operators

优先级: ! > && > ||

2.7 Type Conversions

automatic conversions: convert a "narrower" operand into a "wider" one without losing information

2.11 Conditional Expressions

  • 当两个值的关系符合关系运算符的预期时,关系运算的结果为整数1;否则为整数0

2.12 Precedence and Order of Evaluation

关系运算符的优先级

  • 所有的关系运算符的优先级比算数运算的低,但是比赋值运算的高;
  • 判断是否相等的==和!=的优先级比其他的低,而连续的关系运算是从左到右进行的

Chapter 3 - Control Flow

3.4 Switch

3.5 Loops - While and For

The for statement

for (expr1; expr2; expr3 )
        statement

is equivalent to

expr 1;
while (expr2) {
        statement
        expr3;
}

3.7 Break and Continue

  • break: 跳出当前循环;
  • continue: 跳过本轮循环剩下的语句,进入当前循环的下一轮

3.8 Goto and labels

Chapter 4 - Functions and Program Structure

Chapter 5 - Pointers and Arrays

Chapter 6 - Structures

Chapter 7 - Input and Output

T7.1_Basic_Printf_Conversions.png

T7.2_Basic_Scanf_Conversions.png

Chapter 8 - The UNIX System Interface

The book

http://www.iups.org/media/meeting_minutes/C.pdf


CategoryProgramming

  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01
  • Page.execute = 0.053s
  • getACL = 0.000s
  • init = 0.001s
  • load_multi_cfg = 0.000s
  • run = 0.088s
  • send_page = 0.084s
  • send_page_content = 0.055s
  • send_page_content|1 = 0.027s
  • send_page|1 = 0.027s
  • total = 0.089s