Practical C Programming (Nutshell Handbooks)

Practical C Programming (Nutshell Handbooks)

Language: English

Pages: 456

ISBN: 1565923065

Format: PDF / Kindle (mobi) / ePub


There are lots of introductory C books, but this is the first one that has the no-nonsense, practical approach that has made Nutshell Handbooks® famous.C programming is more than just getting the syntax right. Style and debugging also play a tremendous part in creating programs that run well and are easy to maintain. This book teaches you not only the mechanics of programming, but also describes how to create programs that are easy to read, debug, and update.Practical rules are stressed. For example, there are fifteen precedence rules in C (&& comes before || comes before ?:). The practical programmer reduces these to two:

  • Multiplication and division come before addition and subtraction.

Contrary to popular belief, most programmers do not spend most of their time creating code. Most of their time is spent modifying someone else's code. This books shows you how to avoid the all-too-common obfuscated uses of C (and also to recognize these uses when you encounter them in existing programs) and thereby to leave code that the programmer responsible for maintenance does not have to struggle with. Electronic Archaeology, the art of going through someone else's code, is described.This third edition introduces popular Integrated Development Environments on Windows systems, as well as UNIX programming utilities, and features a large statistics-generating program to pull together the concepts and features in the language.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

It can hold only one integer and describe only one total. A series of integers can be organized into an array as follows: int balance[100]; /* Balance (in cents) for all 100 accounts */ Again, C will handle the details of imposing that organization on the computer’s memory. Finally, there are more complex data types. For example, a rectangle might have a width, a height, a color, and a fill pattern. C lets us organize these four items into one group called a structure. struct rectangle { int

............................................................................ 156 Bit Operators .................................................................................................. 158 The and Operator (&) .................................................................................... 158 Bitwise or (|) ................................................................................................. 160 The Bitwise Exclusive or (^)

before the assignment. However, number 4 is a much better answer. The main effects of C are confusing enough without having to worry about side effects. NOTE Some programmers value compact code very highly. This attitude is a holdover from the early days of computing when storage cost a significant amount of money. I believe that the art of programming has evolved to the point where clarity is much more valuable than compactness. (Great novels, which a lot of people enjoy reading, are not

programming, as shown in the following example: switch, break, and continue 123 /* The final version */ switch (control) { case 0: printf("Reset\n"); /* Fall through */ case 1: printf("Initializing\n"); break; case 2: printf("Working\n"); break; default: printf( "Internal error, control value (%d) impossible\n", control); break; } Although a default is not required, it should be put in every switch. Even though the default may be: default: /* Do nothing */ break; it should be included. This

++permanent; } return (0); } The output of this program is: Temporary 1 Permanent 1 Temporary 1 Permanent 2 Temporary 1 Permanent 3 NOTE Temporary variables are sometimes referred to as automatic variables because the space for them is allocated automatically. The qualifier auto can be used to denote a temporary variable; however, in practice it is almost never used. Table 9-1 describes the different ways in which a variable can be declared. Table 9-1: Declaration Modifiers Declared Scope

Download sample

Download