The C programming language (second edition,K&R) exercise(测试环境)

本文讲述了初学者如何通过谭浩强的教材入门C语言后,转向更经典的《TheCProgrammingLanguage》(K&R)第二版,介绍了使用GCC编译器在Windows上安装和配置环境的过程,包括从VisualStudio替代品到Linux环境的切换,以及如何编译和运行Hello,World程序。
摘要由CSDN通过智能技术生成

     相信大多数人和我一样 C C C语言的启蒙教材都是谭浩强爷爷的那本绿皮的教材,虽然网上很多人骂,但是我觉得这本教材对于初学者来说还是比较合适的。当我们有了一定的 C C C语言基础并有了一些项目实战经验之后我们可以再回过头来去阅读一些比较经典的教材以此来作为提升,接下来我准备学习一下 C C C语言的经典教材 《 T h e C P r o g r a m m i n g L a n g u a g e 》 , S e c o n d E d i t i o n , K & R 《The\quad C\quad Programming\quad Language》,Second\quad Edition,K \&R TheCProgrammingLanguage,SecondEdition,K&R,如图1所示,这本教材中有很多练习题,这里我记录一下测试练习题的编译环境的安装过程。

 
图1.

     这里我没有使用微软的 V i s u a l S t u d i o Visual\quad Studio VisualStudio,一是这个编译环境本身太大了,安装需要很大的硬盘存储空间,二是在实际的工作中,很多需要实在 L i n u x Linux Linux环境下。因此这里我采用的编译环境如图2所示,官网在这里。我对这个东西其实了解的也不多,最基本的了解就是它实现了将 G C C GCC GCC编译器搬到了 W i n d o w s Windows Windows平台且通过 G C C GCC GCC编译器编译的程序可以直接在 W i n d o w s Windows Windows平台执行,更多详细内容可以自己去官网或者查资料。

 
图2.

     这里我只是简单的记录一下安装的过程,详细的安装过程请参考这里,我基本也是参考它的。安装过程很简单,首先进入图3中红圈的链接,接着进入图4中红圈的链接,最后进入到图5选择对应的版本和相应的包下载(具体如何选择还是请参考这里),其实图5中蓝色的圈下载下来的东西就是一个网络包的下载器,它的作用就是会自动下载红圈对应的相关包,没啥特别的作用,有些在用这个网络包的下载器的时候可能会出现下载失败的情况,所以为了方便直接下载红圈中对应的包就可以了。

 
图3.
 
图4.
 
图5.

     包下载完解压之后如图6所示,然后将图6中 b i n bin bin目录的完整目录添加到图7中的环境变量的系统变量里面的 p a t h path path变量里面就算安装完成了。然后进入图8所示的命令提示符输入命令 g c c − v gcc\quad -v gccv也有图8对应的输出的话就算安装成功了。

 
图6.
 
图7.
 
图8.

     然后我们使用 N o t e p a d + + Notepad++ Notepad++写一个简单的 H e l l o , W o r l d Hello,World Hello,World程序,如图9所示,然后在命令提示符中定位到这个代码文件所在的目录,然后使用 g c c gcc gcc命令来编译这个代码源文件,最后会在代码文件所在的目录生成一个对应代码文件的可执行的 e x e exe exe文件,如图10所示,最后我们在命令提示符窗口中直接输出这个 e x e exe exe文件的完整文件名就可以执行它了,结果如图11所示。

 
图9.
 
图10.
 
图11.

     好了,编译环境我们这里基本上就弄完了,这里需要注意的是接下来的练习的代码实现并不是我自己实现的,我也是参考的这里还有以下两个 g i t h u b github github项目也可以参考:

  • 13
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
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
发出的红包

打赏作者

qqssss121dfd

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值