• Complain

Zambon - Practical C

Here you can read online Zambon - Practical C full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. City: Berkeley;CA, year: 2016, publisher: Apress, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Zambon Practical C
  • Book:
    Practical C
  • Author:
  • Publisher:
    Apress
  • Genre:
  • Year:
    2016
  • City:
    Berkeley;CA
  • Rating:
    5 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 100
    • 1
    • 2
    • 3
    • 4
    • 5

Practical C: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Practical C" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Learn practical C techniques, including often-needed algorithms within reusable functions. In this book, youll have the following code and advice at your fingertips: layout and pre-processors; control structures, iterations, and selections; pointers and structures; databases; reusability; lists, arrays, FIFO and stacks; searching and sorting; recursion; binary trees; integration; string utilities in/outside of C; web serving using Mongoose; game application code to build a MathSearch puzzle; and embedded software. Besides providing you with modules that you can immediately put to use, Practical C also teaches you how to leverage the C language in a way that beginner books cannot achieve. What You Will Learn: Avoid pitfalls that can cause intractable problems Handle lists and arrays Perform searches and sorts Binary trees Take advantage of recursion Handle exceptions Access databases Calculate integrals using numerical computation with practical applications Deal with strings in a convenient, error-free way Build a MathSearch game application, similar to WordSearch puzzle games Deal with issues specific to embedded applications Who This Book Is For Programmers who have a general knowledge of C.;1. Introduction -- 2. Tricky Bits -- 3. Iteration, Recursion, and Binary Trees -- 4. Lists, Queues, and Stacks -- 5. Exception Handling -- 6. String Utilities -- 7. Dynamic Arrays -- 8. Searching -- 9. Sorting -- 10. Numerical Integration -- 11. Embedded Software -- 12. Databases -- 13. Web Server using Mongoose -- 14. Game App: MathSearch -- Appendix A: Abbreviations and Acronyms -- Appendix B: Introduction to SQL.

Zambon: author's other books


Who wrote Practical C? Find out the surname, the name of the author of the book and a list of all author's works by series.

Practical C — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Practical C" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Giulio Zambon 2016
Giulio Zambon Practical C 10.1007/978-1-4842-1769-6_1
1. Introduction
Giulio Zambon 1
(1)
Harrison, Aust Capital Terr, Australia
Electronic supplementary material
The online version of this chapter (doi: 10.1007/978-1-4842-1769-6_1 ) contains supplementary material, which is available to authorized users.
Because this is a book of recipes, you will not find a description of C, although to ensure that we are all on the same page (pun entirely intended!), I sometimes include brief explanations of individual features of the language. Chapter also covers some aspects of C that are often sources of mistakes.
For an introduction to C, you can refer to the classical K&R (Kernighans and Ritchies The C Programming Language ), Apresss own Beginning C , by Ivor Horton, and a number of other books specifically on the subject.
I have developed all the recipes described in this book using the GNU Compiler Collection (gcc) version 4.8.4 within the Eclipse development environment (release 4.5.0, Mars) running under Linux-GNU Ubuntu 14.04 LTS on a 64-bit laptop.
The current version of the C standard is ISO/IEC 9899:2011 , usually referred to as C11, which extends the previous version of the standard (ISO/IEC 9899:1999, nicknamed C99). The gcc C compiler supports C99 and C11. For a complete list of gcc options concerning versions of C, you can refer to gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html .
You need to compile most of the code you will find in this book with the -std=c99 option because I use the Java-like format of for loops, with the control-variable definition included in the for statement . For example:
for (int k = 0; k < N; k++)
Previous versions of C require you to define the control variable outside the for statement, as such:
int k;
for (k = 0; k < N; k++)
Coding Style
There are several aspects that constitute a coding style. By understanding my coding style, which I have obviously used in all examples in this book, you will find it easier to follow my code.
Indentation
Looking at the source code attached to this book, you will notice that all closed braces that end block statements are indented, as shown in Listing .
1. void dar_list(Dar *stk) {
2. if (stk == NULL) {
3. printf("Nothing to list\n");
4. }
5. while (stk != NULL) {
6. printf("%p %zu %zu\n", stk, stk->size, stk->n);
7. stk = stk->down;
8. }
9. }
Listing 1-1.
The Authors Coding Style
The open braces in lines 1, 2, and 5 are appended to the previous line, while the closed braces in lines 4, 8, and 9 are indented. This style must be unusual because Eclipse and other development environments do not foresee it, while the two widely used styles shown in Listings are fully supported.
1. void dar_list(Dar *stk)
2. {
3. if (stk == NULL)
4. {
5. printf("Nothing to list\n");
6. }
7. while (stk != NULL)
8. {
9. printf("%p %zu %zu\n", stk, stk->size, stk->n);
10. stk = stk->down;
11. }
12. }
Listing 1-2.
Spread-Out Coding Style
The spread-out style of Listing . Obviously, if you need to achieve targets based on number of written lines of code, you might like to adopt this style!
1. void dar_list(Dar *stk) {
2. if (stk == NULL) {
3. printf("Nothing to list\n");
4. }
5. while (stk != NULL) {
6. printf("%p %zu %zu\n", stk, stk->size, stk->n);
7. stk = stk->down;
8. }
9. }
Listing 1-3.
Compact Not-Indented Coding Style
The style shown in Listing is probably the most widely used. The K&R uses it (with the exception of writing the open brace that begins a function body on a new line). It is good but, IMO, it has two problems: one conceptual and one practical.
The conceptual problem is that both braces delimiting a block statement belong to the block statement itself, which is indented. Then, why shouldnt the closing brace (and, in the case of the spread-out style, the opening brace too) be indented as well? For example, the closing brace in line 8 of Listing belongs to the block statement that begins in line 5 and contains the printf() and the assignment to stk . Then, it should be placed below the s of stk , rather than below the w of while .
The practical problem is that by not indenting the closed braces, you compromise the visual clarity of what I call the flagging effect. To illustrate what the flagging effect is, I took a screenshot of Listing by adding some shading.
Figure 1-1 The flagging effect of my coding style As you can see - photo 1
Figure 1-1.
The flagging effect of my coding style
As you can see, everything that depends on the if -condition hangs from the if statement, and everything contained in the while -loop hangs from the while statement. This definitely makes reading the source code easier.
One more word concerning if s and else s.
I often see chains of if s and else s written like this:
if (condition 1) {
...
} else if (condition 2) {
...
} else {
...
}
This might be graphically pleasing and very compact, but it doesnt reflect the fact that the if s and the else s are not shown to be at the same level (which they are). Here is how I would write such a piece of code:
if (condition 1) {
...
}
else if (condition 2) {
...
}
else {
...
}
Naming and Other Conventions
This book includes several libraries of functions, each one consisting of a C file and the corresponding header file (e.g., string.c and string.h ). Each library is characterized by a small number of identifying letters that prefix the names of all exported macros, variables, and functions (e.g., str ). Macro constants (i.e., macros without parameters) are in capital letters (e.g., STR_LOG ), while with names of function-like macros only the prefix is capitalized (e.g., STR_crash() ). In names of exported variables and functions, the prefix is in lowercase (e.g., str_stack and str_list() ).
The names of most integer variables begin with a letter in the range i to n , especially if they are very short. This is a legacy of my initial experience with computers: the first computer language I learned (more than 40 years ago!) was FORTRAN, which automatically identified variables with names beginning with one of those letters to be of type INTEGER . I have to admit I am not perfectly consistent in following this rule when naming integer variables, but you will never find in my code a non-integer variable that starts with one of the integer letters. I simply couldnt!
If you look at modules containing several functions, you will perhaps notice that the functions are in alphabetical order, so that you always find them at once without having to search for them. To be able to refer to non-exported functions regardless of where they are within the module, I declare them at the beginning of the C file.
Also for convenience, I write a line of comment immediately before each function, with the name of the function on the far right:
//---------------------------------------------------------------- str_clean_up
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Practical C»

Look at similar books to Practical C. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Practical C»

Discussion, reviews of the book Practical C and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.