再读《The C Programming language》 - 第一章 1.1 入门

本文通过探讨经典的Hello, World!程序及其背后的意义,为初学者提供了C语言学习的实用建议。文章通过两个练习介绍了错误排查的重要性,并鼓励学习者通过实验加深理解。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.1 入门

第一章开始 K&R大师给出了经典的Hello,world!程序,如此轻松的带我们进入了神奇的C语言世界~,有个笑话是这样的“有个资深程序员想业余时间培养下其他爱好,于是想去练习书法,网上邮购了上好的笔墨纸砚,铺开宣纸,提起羊毫,毫不怀疑的写了“Hello,World!”12个字符” 可见这个程序的我们“苦逼”的程序员影响有多大!


书中的言简意赅的内容这里,我就不赘述了,直接跳到其两个练习来:


Exercise 1-1. Run the ‘‘hello, world’’ program on your system. Experiment with leaving out parts of the program, to see 
what error messages you get. 


大师为什么给我们的第一道练习是试错练习呢?所以说大师就是大师!其实,相比学习C的孩童虽然学习着这个简单的Hello,world!程序,但我相信只有少数的孩童是一次行,敲代码,编译,运行成功的!大部分鞋童都是或多或少这里哪里出错!然后回头去一个单词一个单词的比对~哇靠“main”-->"mian" 那绝对是常有的事!如果编译器不帮我们找茬~那可就苦了鞋童们啦~~~所以这个练习不用可以做了,你在动手写自己第一个程序就遇到了~~~

Exercise 1-2. Experiment to find out what happens when prints’s argument string contains \c, where c is some character not 
listed above. 


第二个练习就有点难度了,当然看看可以,如果要求深解的话,那就要有一定的基础了,写个程序看看就可以了,至于你要问为什么?那随着深入的学习,你就了解了,就像你现在会做N*n的乘法,会解微积分,也是从1+1开始学习过来的,但由于时间久了,站在这个1+1的巨人的肩膀久了,你渐渐就忘记了这个巨人的存在!学习C语言也是一个积累的过程,一步是吃不成胖子的,遇到问题也不要灰心,慢慢来,慢慢的就发现自己成功了!

该题的解释('\c'就表示字符'c'。在C语言中,除非有特别规定(转义字符),如'\n'表示回车,否则斜扛及后面字符就表示字符本身




The C programming Language By Brian W. Kernighan and Dennis M. Ritchie. Published by Prentice-Hall in 1988 ISBN 0-13-110362-8 (paperback) ISBN 0-13-110370-9 目录结构: Contents Preface Preface to the first edition Introduction Chapter 1: A Tutorial Introduction Getting Started Variables and Arithmetic Expressions The for statement Symbolic Constants Character Input and Output File Copying Character Counting Line Counting Word Counting Arrays Functions Arguments - Call by Value Character Arrays External Variables and Scope Chapter 2: Types, Operators and Expressions Variable Names Data Types and Sizes Constants Declarations Arithmetic Operators Relational and Logical Operators Type Conversions Increment and Decrement Operators Bitwise Operators Assignment Operators and Expressions Conditional Expressions Precedence and Order of Evaluation Chapter 3: Control Flow Statements and Blocks If-Else Else-If Switch Loops - While and For Loops - Do-While Break and Continue Goto and labels Chapter 4: Functions and Program Structure Basics of Functions Functions Returning Non-integers External Variables Scope Rules Header Files Static Variables Register Variables Block Structure Initialization Recursion The C Preprocessor File Inclusion Macro Substitution Conditional Inclusion Chapter 5: Pointers and Arrays Pointers and Addresses Pointers and Function Arguments Pointers and Arrays Address Arithmetic Character Pointers and Functions Pointer Arrays; Pointers to Pointers Multi-dimensional Arrays Initialization of Pointer Arrays Pointers vs. Multi-dimensional Arrays Command-line Arguments Pointers to Functions Complicated Declarations Chapter 6: Structures Basics of Structures Structures and Functions Arrays of Structures Pointers to Structures Self-referential Structures Table Lookup Typedef Unions Bit-fields Chapter 7: Input and Output Standard Input and Output Formatted Output - printf Variable-length Argument Lists Formatted Input - Scanf File Access Error Handling - Stderr and Exit Line Input and Output Miscellaneous Functions String Operations Character Class Testing and Conversion Ungetc Command Execution Storage Management Mathematical Functions Random Number generation Chapter 8: The UNIX System Interface File Descriptors Low Level I/O - Read and Write Open, Creat, Close, Unlink Random Access - Lseek Example - An implementation of Fopen and Getc Example - Listing Directories Example - A Storage Allocator Appendix A: Reference Manual Introduction Lexical Conventions Syntax Notation Meaning of Identifiers Objects and Lvalues Conversions Expressions Declarations Statements External Declarations Scope and Linkage Preprocessor Grammar Appendix B: Standard Library Input and Output: <stdio.h> File Operations Formatted Output Formatted Input Character Input and Output Functions Direct Input and Output Functions File Positioning Functions Error Functions Character Class Tests: <ctype.h> String Functions: <string.h> Mathematical Functions: <math.h> Utility Functions: <stdlib.h> Diagnostics: <assert.h> Variable Argument Lists: <stdarg.h> Non-local Jumps: <setjmp.h> Signals: <signal.h> Date and Time Functions: <time.h> Implementation-defined Limits: <limits.h> and <float.h> Appendix C: Summary of Changes
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值