Home > Store

Programming in C, 4th Edition

eBook

  • Your Price: $38.39
  • List Price: $47.99
  • Includes EPUB and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    Adobe Reader PDF The popular standard, used most often with the free Acrobat® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

Also available in other formats.

Register your product to gain access to bonus material or receive a coupon.

Description

  • Copyright 2015
  • Dimensions: 7" x 9"
  • Pages: 544
  • Edition: 4th
  • eBook
  • ISBN-10: 0-13-278121-2
  • ISBN-13: 978-0-13-278121-3

Programming in C will teach you how to write programs in the C programming language. Whether you’re a novice or experienced programmer, this book will provide you with a clear understanding of this language, which is the foundation for many object-oriented programming languages such as C++, Objective-C, C#, and Java.

This book teaches C by example, with complete C programs used to illustrate each new concept along the way. Stephen Kochan provides step-by-step explanations for all C functions. You will learn both the language fundamentals and good programming practices. Exercises at the end of each chapter make the book ideally suited for classroom use or for self-instruction.

All the features of the C language are covered in this book, including the latest additions added with the C11 standard. Appendixes provide a detailed summary of the language and the standard C library, both organized for quick reference.

“Absolutely the best book for anyone starting out programming in C. This is an excellent introductory text with frequent examples and good text.…This is the book I used to learn C–it’s a great book.”

Vinit S. Carpenter, Learn C/C++ Today

Sample Content

Table of Contents

    Introduction 1

1 Some Fundamentals 5

    Programming 5

    Higher-Level Languages 5

    Operating Systems 6

    Compiling Programs 7

    Integrated Development Environments 10

    Language Interpreters 10

2 Compiling and Running Your First Program 11

    Compiling Your Program 12

    Running Your Program 12

    Understanding Your First Program 13

    Displaying the Values of Variables 15

    Comments 17

    Exercises 19

3 Variables, Data Types, and Arithmetic Expressions 21

    Understanding Data Types and Constants 21

        The Integer Type int 22

        The Floating Number Type float 23

        The Extended Precision Type double 23

        The Single Character Type char 24

        The Boolean Data Type _Bool 24

        Type Specifiers: long, long long, short, unsigned, and signed 26

    Working with Variables 29

    Working with Arithmetic Expressions 30

        Integer Arithmetic and the Unary Minus Operator 33

    Combining Operations with Assignment: The Assignment Operators 39

    Types _Complex and _Imaginary 40

    Exercises 40

4 Program Looping 43

    Triangular Numbers 43

    The for Statement 44

        Relational Operators 46

        Aligning Output 50

    Program Input 51

        Nested for Loops 53

        for Loop Variants 55

    The while Statement 56

    The do Statement 60

        The break Statement 62

        The continue Statement 62

    Exercises 63

5 Making Decisions 65

    The if Statement 65

        The if-else Construct 69

        Compound Relational Tests 72

        Nested if Statements 74

        The else if Construct 76

    The switch Statement 83

    Boolean Variables 86

    The Conditional Operator 90

    Exercises 92

6 Working with Arrays 95

    Defining an Array 96

        Using Array Elements as Counters 100

        Generating Fibonacci Numbers 103

        Using an Array to Generate Prime Numbers 104

    Initializing Arrays 106

    Character Arrays 108

        Base Conversion Using Arrays 109

        The const Qualifier 111

    Multidimensional Arrays 113

    Variable Length Arrays 115

    Exercises 117

7 Working with Functions 119

    Defining a Function 119

    Arguments and Local Variables 123

        Function Prototype Declaration 124

        Automatic Local Variables 124

    Returning Function Results 126

    Functions Calling Functions Calling... 130

        Declaring Return Types and Argument Types 133

        Checking Function Arguments 135

    Top-Down Programming 137

    Functions and Arrays 137

        Assignment Operators 141

        Sorting Arrays 143

        Multidimensional Arrays 146

    Global Variables 151

    Automatic and Static Variables 155

    Recursive Functions 158

    Exercises 161

8 Working with Structures 163

    The Basics of Structures 163

    A Structure for Storing the Date 164

        Using Structures in Expressions 166

    Functions and Structures 169

        A Structure for Storing the Time 175

    Initializing Structures 178

        Compound Literals 178

    Arrays of Structures 180

    Structures Containing Structures 183

    Structures Containing Arrays 185

    Structure Variants 189

    Exercises 190

9 Character Strings 193

    Revisiting the Basics of Strings 193

    Arrays of Characters 194

    Variable-Length Character Strings 197

        Initializing and Displaying Character Strings 199

        Testing Two Character Strings for Equality 202

        Inputting Character Strings 204

        Single-Character Input 206

        The Null String 211

    Escape Characters 215

    More on Constant Strings 217

    Character Strings, Structures, and Arrays 218

        A Better Search Method 221

    Character Operations 226

    Exercises 229

10 Pointers 233

    Pointers and Indirection 233

    Defining a Pointer Variable 234

    Using Pointers in Expressions 237

    Working with Pointers and Structures 239

        Structures Containing Pointers 241

        Linked Lists 243

    The Keyword const and Pointers 251

    Pointers and Functions 252

    Pointers and Arrays 258

        A Slight Digression About Program Optimization 262

        Is It an Array or Is It a Pointer? 262

        Pointers to Character Strings 264

        Constant Character Strings and Pointers 266

        The Increment and Decrement Operators Revisited 267

    Operations on Pointers 271

    Pointers to Functions 272

    Pointers and Memory Addresses 273

    Exercises 275

11 Operations on Bits 277

    The Basics of Bits 277

    Bit Operators 278

        The Bitwise AND Operator 279

        The Bitwise Inclusive-OR Operator 281

        The Bitwise Exclusive-OR Operator 282

        The Ones Complement Operator 283

        The Left Shift Operator 285

        The Right Shift Operator 286

        A Shift Function 286

        Rotating Bits 288

    Bit Fields 291

    Exercises 295

12 The Preprocessor 297

    The #define Statement 297

        Program Extendability 301

        Program Portability 302

        More Advanced Types of Definitions 304

        The # Operator 309

        The ## Operator 310

    The #include Statement 311

        System Include Files 313

    Conditional Compilation 314

        The #ifdef, #endif, #else, and #ifndef Statements 314

        The #if and #elif Preprocessor Statements 316

        The #undef Statement 317

    Exercises 318

13 Extending Data Types with the Enumerated Data Type, Type Definitions, and Data Type Conversions 319

    Enumerated Data Types 319

    The typedef Statement 323

    Data Type Conversions 325

        Sign Extension 327

        Argument Conversion 328

    Exercises 329

14 Working with Larger Programs 331

    Dividing Your Program into Multiple Files 331

        Compiling Multiple Source Files from the Command Line 332

    Communication Between Modules 334

        External Variables 334

        Static Versus Extern Variables and Functions 337

        Using Header Files Effectively 339

    Other Utilities for Working with Larger Programs 341

        The make Utility 341

        The cvs Utility 343

        Unix Utilities: ar, grep, sed, and so on 343

15 Input and Output Operations in C 345

    Character I/O: getchar() and putchar() 346

    Formatted I/O: printf() and scanf() 346

        The printf() Function 346

        The scanf() Function 353

    Input and Output Operations with Files 358

        Redirecting I/O to a File 358

        End of File 361

    Special Functions for Working with Files 362

        The fopen Function 362

    The getc() and putc() Functions 364

        The fclose() Function 365

        The feof Function 367

        The fprintf() and fscanf() Functions 367

        The fgets() and fputs() Functions 367

        stdin, stdout, and stderr 368

        The exit() Function 369

        Renaming and Removing Files 370

    Exercises 371

16 Miscellaneous and Advanced Features 373

    Miscellaneous Language Statements 373

        The goto Statement 373

        The null Statement 374

    Working with Unions 375

    The Comma Operator 378

    Type Qualifiers 379

        The register Qualifier 379

        The volatile Qualifier 379

        The restrict Qualifier 379

    Command-line Arguments 380

    Dynamic Memory Allocation 384

        The calloc() and malloc() Functions 385

        The sizeof Operator 385

        The free Function 387

    Exercises 389

17 Debugging Programs 391

    Debugging with the Preprocessor 391

    Debugging Programs with gdb 397

        Working with Variables 400

        Source File Display 401

        Controlling Program Execution 402

        Getting a Stack Trace 406

        Calling Functions and Setting Arrays and Structures 407

        Getting Help with gdb Commands 408

        Odds and Ends 410

18 Object-Oriented Programming 413

    What Is an Object Anyway? 413

    Instances and Methods 414

    Writing a C Program to Work with Fractions 416

    Defining an Objective-C Class to Work with Fractions 417

    Defining a C++ Class to Work with Fractions 421

    Defining a C# Class to Work with Fractions 424

A C Language Summary 427

B The Standard C Library 471

C Compiling Programs with gcc 495

D Common Programming Mistakes 499

E Resources 505

TOC, 9780321776419, 7/28/2014

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020