The C Programming Language Reading Notes 1

Source: Internet
Author: User



I Love Tiananmen, Beijing


Sun rises on Tiananmen


Great leader Chairman Mao


Guide us forward


<P class = "msonormal" style = "margin: 0 cm 0 cm 0pt"> <span style = "font-size: 14pt; font-family:; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family: 'times new Roman' "> note range: </span> <SPAN lang = "en" style = "font-size: 14pt"> the C programming language </span> <Span
Style = "font-size: 14pt; font-family:; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family: 'times new Roman '"> Chapter 1 </span> <SPAN lang =" en "style =" font-size: 14pt "> <? XML: namespace prefix = o ns = "urn: Schemas-Microsoft-com: Office: office"/> <O: P> </O: p> </span> </P>
<P class = "msonormal" style = "margin: 0 cm 0 cm 0pt"> <SPAN lang = "en" style = "font-size: 14pt"> <O: p> & nbsp; </O: P> </span> </P> <P class = "msonormal" style = "margin: 0 cm 0 cm 0pt; text-indent: 21pt; MSO-Char-indent-count: 1.5 "> <span style =" font-size: 14pt; font-family:
MSO; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family: 'times new Roman' "> it should be said that, this time, I should have read this book for the fourth time. I have gained a lot from reading this book each time. It has aroused my new thoughts. It is hard to imagine that this small technical book is so profound and memorable. The content of this chapter is a concept that is easy to understand, programming learners have the minimum knowledge, but some things are ignored by beginners. So that beginners in various technical communities are constantly having problems. In fact, these things have been fully explained in the first chapter. The following is just to emphasize them, </span> <Span
Lang = "en" style = "font-size: 14pt"> <O: P> </O: p> </span> </P> <P class = "msonormal" style = "margin: 0 cm 0 cm 0pt 63.75pt; text-indent:-42.75pt; tab-stops: list 63.75pt; MSO-list: l0 level1 lfo1 "> <SPAN lang =" en "style =" font-size: 14pt; MSO-bidi-font-family: ""> <Span
Style = "MSO-list: Ignore"> 1. </span> <span style = "font-size: 14pt; font-family:; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family: 'times new Roman '"> about cyclic termination. In many books, such cyclic statements exist: </span> <SPAN lang = "en" style = "font-size: 14pt"> <O: P> </O: p> </span> </P>
<P class = "msonormal" style = "margin: 0 cm 0 cm 0pt 63.75pt"> <SPAN lang = "en" style = "font-size: 14pt "> while (getchar ()! = EOF) <span style = "MSO-spacerun: yes"> & nbsp; </span> {....} <O: P> </span> </P> <P class = "msonormal" style = "margin: 0 cm 0 cm 0pt 63.75pt"> <Span
Style = "font-size: 14pt; font-family:; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family: 'times new Roman '"> many people do not understand this </span> <SPAN lang =" en "style =" font-size: 14pt "> EOF </span> <span style =" font-size: 14pt; font-family:; MSO-ascii-font-family:
'Times new Roman '; MSO-Hansi-font-family: 'times new Roman' "> Why? How do I perform this operation? So that the preceding statement becomes an infinite loop. In fact, </span> <SPAN lang = "en" style = "font-size: 14pt "> EOF </span> <span style =" font-size: 14pt; font-family:; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family:
'Times new Roman '">. Is the file terminator (</span> <SPAN lang = "en" style = "font-size: 14pt "> end of file </span> <span style =" font-size: 14pt; font-family:; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family: 'times new Roman' ">), which is described in Chapter 7. It is a system constant. The value is </span> <SPAN lang = "en"
Style = "font-size: 14pt">-1 </span> <span style = "font-size: 14pt; font-family:; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family: 'times new Roman' ">, of course, you enter </span> <SPAN lang = "en" style = "font-size: 14pt ">-1 </span> <span style =" font-size: 14pt;
Font-family:; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family: 'times new Roman' ">. The loop is not over, </span> <SPAN lang = "en" style = "font-size: 14pt"> Why </span> <span style = "font-size: 14pt; font-family:; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family:
'Times new Roman '">? </Span> <SPAN lang = "en" style = "font-size: 14pt"> how to do </span> <span style = "font-size: 14pt; font-family:; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family: 'times new Roman' ">? Well, in </span> <SPAN lang = "en" style = "font-size:
14pt "> C </span> <span style =" font-size: 14pt; font-family:; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family: 'times new Roman '"> expert programming, </span> <SPAN lang = "en" style = "font-size: 14pt"> C </span> <span style = "font-size: 14pt; font-family:;
MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family: 'times new Roman' "> the first batch of users are system designers and compiler designers. In their philosophy, information is often measured in files. This flag is only the end of the file, which is generally not provided by the user. The keyboard and other inputs are in </span> <SPAN lang = "en" style = "font-size: 14pt"> OS </span> <span style = "font-size: 14pt; font-family:
MSO; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family: 'times new Roman' "> is an extremely special file. You need to explicitly mark the end of the file. It is said that system constants certainly have system dependencies, so different system flag methods are completely different. </Span> <SPAN lang = "en" style = "font-size: 14pt"> Windows </span> <span style = "font-size: 14pt; font-family:; MSO-ascii-font-family:
'Times new Roman '; MSO-Hansi-font-family: 'times new Roman '"> </span> <SPAN lang =" en "style =" font-size: 14pt "> Ctrl + z </span> <span style =" font-size: 14pt; font-family:; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family: 'times new Roman' ">. </Span> <Span
Lang = "en" style = "font-size: 14pt"> Linux </span> <span style = "font-size: 14pt; font-family:; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family: 'times new Roman '"> </span> <SPAN lang =" en "style =" font-size: 14pt "> Ctrl + D. </span> <span style = "font-size:
14pt; font-family:; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family: 'times new Roman '"> In addition, </span> <SPAN lang =" en "style =" font-size: 14pt "> EOF </span> <span style =" font-size: 14pt; font-family:; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family:
'Times new Roman '"> In fact, explicit descriptions are not needed. The above code is equivalent to this: </span> <SPAN lang = "en" style = "font-size: 14pt"> <O: P> </O: p> </span> </P> <P class = "msonormal" style = "margin: 0 cm 0 cm 0pt 63.75pt "> <SPAN lang =" en "style =" font-size: 14pt "> while (getchar ()){......} <O: P> </span> </P> <p
Class = "msonormal" style = "margin: 0 cm 0 cm 0pt 63.75pt; text-indent:-42.75pt; tab-stops: List 63.75pt; MSO-list: l0 level1 lfo1 "> <SPAN lang =" en "style =" font-size: 14pt; MSO-bidi-font-family: "> <span style =" MSO-list: Ignore "> 2. </span> <span style = "font-size:
14pt; font-family:; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family: 'times new Roman '"> description and definition. Although we all know about this issue, there are not many people who really make it clear. Some people think that the declaration and definition of variables are no different. Some people think this is related to initialization (I used to be such an idiot, Khan ~~~), The latter simply does not understand these two concepts. The Declaration just gives the compiler a prompt that such a name exists in the program and has nothing to do with the runtime environment. It can be repeated. The definition is to allocate memory space and specify the variable's seat (left value), which can only appear once in the same domain. In a single file program. Almost no error found. However, if you put such a sentence in the header file, </span> <Span
Lang = "en" style = "font-size: 14pt"> int A </span> <span style = "font-size: 14pt; font-family:; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family: 'times new Roman' ">; once this header file is repeated. A link error is inevitable. In fact: </span> <SPAN lang = "en" style = "font-size: 14pt"> <br
/> Extern int A; // </span> <span style = "font-size: 14pt; font-family:; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family: 'times new Roman' "> statement </span> <SPAN lang =" en "style =" font-size: 14pt "> <br/> int A; // </span> <span style =" font-size: 14pt; font-family:
; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family: 'times new Roman '"> definition </span> <SPAN lang =" en "style =" font-size: 14pt "> <O: P> </O: p> </span> </P> <P class = "msonormal" style = "margin: 0 cm 0 cm 0pt 63.75pt; text-indent:-42.75pt; tab-stops: List
63.75pt; MSO-list: l0 level1 lfo1 "> <SPAN lang =" en "style =" font-size: 14pt; MSO-bidi-font-family: "> <span style =" MSO-list: Ignore "> 3. </span> <span style = "font-size: 14pt; font-family:; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family:
'Times new Roman '"> character array and string. Some people think these two are the same concept. Is that true? No, none at all. The former is a container (Data Structure) </span> <SPAN lang = "en" style = "font-size: 14pt">, </span> <span style = "font-size: 14pt; font-family:; MSO-ascii-font-family: 'times new Roman '; MSO-Hansi-font-family: 'times new Roman '"> the latter is data. This may be too theoretical. Well, let's rewrite the </span> <Span
Lang = "en" style = "font-size: 14pt"> Hello World <br/> # include & lt; stdio. H & gt; <O: P> </span> </P> <P class = "msonormal" style = "margin: 0 cm 0 cm 0pt 21pt; text-indent: 42pt; MSO-Char-indent-count: 3.0; MSO-Para-margin-left: 2.0gd "> <SPAN lang =" en "style =" font-size:
14pt "> # include & lt; stdlib. H & gt; <O: P> </span> </P> <P class = "msonormal" style = "margin: 0 cm 0 cm 0pt 21pt; text-indent: 49pt; MSO-Char-indent-count: 3.5; MSO-Para-margin-left: 2.0gd "> int main ()

{
Printf ("/0 Hello World ");


System ("pause ");

Return 0;

}
Oh, nothing? Yes. Do you still remember how the string ends? /0 "/0 Hello world" is a constant array. But the string is "". Character arrays and character lengths are different,

This chapter is very simple, but every example is classic. You can learn something you can't learn from the code. We recommend that you copy each one,

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.