C The Complete Reference Index PDF
C The Complete Reference Index PDF
C
The Complete Reference
Fourth Edition
Page ii
C
The Complete Reference
Fourth Edition
Herbert Schildt
Page iv
Copyright © 2000 by The McGraw-Hill Companies. All rights reserved. Manufactured in the United
States of America. Except as permitted under the United States Copyright Act of 1976, no part of
this publication may be reproduced or distributed in any form or by any means, or stored in a
database or retrieval system, without the prior written permission of the publisher.
0-07-213295-7
The material in this eBook also appears in the print version of this title: 0-07-212124-6.
All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after
every occurrence of a trademarked name, we use names in an editorial fashion only, and to the
benefit of the trademark owner, with no intention of infringement of the trademark. Where such
designations appear in this book, they have been printed with initial caps.
McGraw-Hill eBooks are available at special quantity discounts to use as premiums and sales
promotions, or for use in corporate training programs. For more information, please contact George
Hoare, Special Sales, at [email protected] or (212) 904-4069.
TERMS OF USE
This is a copyrighted work and The McGraw-Hill Companies, Inc. (''McGraw-Hill") and its
licensors reserve all rights in and to the work. Use of this work is subject to these terms. Except as
permitted under the Copyright Act of 1976 and the right to store and retrieve one copy of the work,
you may not decompile, disassemble, reverse engineer, reproduce, modify, create derivative works
based upon, transmit, distribute, disseminate, sell, publish or sublicense the work or any part of it
without McGraw-Hill's prior consent. You may use the work for your own noncommercial and
personal use; any other use of the work is strictly prohibited. Your right to use the work may be
terminated if you fail to comply with these terms.
THE WORK IS PROVIDED "AS IS". McGRAW-HILL AND ITS LICENSORS MAKE NO
GUARANTEES OR WARRANTIES AS TO THE ACCURACY, ADEQUACY OR
COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK,
INCLUDING ANY INFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA
HYPERLINK OR OTHERWISE, AND EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. McGraw-Hill and its
licensors do not warrant or guarantee that the functions contained in the work will meet your
requirements or that its operation will be uninterrupted or error free. Neither McGraw-Hill nor its
licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless of
cause, in the work or for any damages resulting therefrom. McGraw-Hill has no responsibility for
the content of any information accessed through the work. Under no circumstances shall McGraw-
Hill and/or its licensors be liable for any indirect, incidental, special, punitive, consequential or
similar damages that result from the use of or inability to use the work, even if any of them has been
advised of the possibility of such damages. This limitation of liability shall apply to any claim or
cause whatsoever whether such claim or cause arises in contract, tort or otherwise.
DOI: 10.1036/0-07-213295-7
Page v
CONTENTS
Preface xxiii
Part I
Foundational C
1 3
An Overview of C
A Brief History of C 4
C Is a Middle-Level Language 5
C Is a Structured Language 6
C Is a Programmer's Language 8
Separate Compilation 12
Compiling a C Program 13
C Vs. C++ 14
Review of Terms 15
Page vi
2 17
Expressions
Identifier Names 20
Variables 21
Local Variables 22
Formal Parameters 25
Global Variables 26
Type Qualifiers 28
const 28
volatile 30
extern 31
static Variables 33
register Variables 35
Variable Initializations 36
Constants 37
String Constants 38
Arithmetic Operators 43
Bitwise Operators 48
The ? Operator 53
Precedence Summary 58
Expressions 58
Order of Evaluation 58
Casts 60
3 63
Statements
Selection Statements 64
if 64
Nested ifs 66
The ? Alternative 69
switch 72
Iteration Statements 76
Jump Statements 87
Expression Statements 93
Block Statements 93
4 95
Arrays and Strings
Single-Dimension Arrays 96
Strings 99
5 119
Pointers
6 147
Functions
Team-Fly®
The return Statement 158
Recursion 164
7 173
Structures, Unions, Enumerations, and typedef
Structures 174
Unions 193
Bit-Fields 195
Enumerations 198
typedef 203
8 205
Console I/O
printf( ) 212
Printing Characters 213
scanf( ) 221
9 229
File I/O
Streams 231
Files 231
rewind( ) 240
ferror( ) 241
10 261
The Preprocessor and Comments
#define 262
#error 265
#include 265
#undef 270
#line 271
Page xi
#pragma 272
Comments 274
Part II
The C99 Standard
11 279
C99
inline 282
_Bool 284
Part III
The C Standard Library
12 301
Linking, Libraries, and Headers
Headers 305
13 309
I/O Functions
clearerr 310
fclose 312
feof 313
ferror 313
fflush 314
fgetc 315
fgetpos 316
fgets 317
fopen 318
fprintf 320
fputc 321
fputs 321
fread 322
freopen 323
fscanf 324
fseek 325
fsetpos 326
ftell 327
fwrite 328
getc 329
getchar 330
gets 331
perror 332
printf 332
putc 336
putchar 337
puts 337
Page xiii
remove 338
rename 339
rewind 340
scanf 340
setbuf 345
setvbuf 345
snprintf 346
sprintf 347
sscanf 347
Y
FL
tmpfile 348
AM
tmpnam 349
ungetc 350
TE
14 353
String and Character Functions
isalnum 354
isalpha 355
isblank 356
iscntrl 357
isdigit 358
isgraph 358
Team-Fly®
islower 359
isprint 360
ispunct 361
isspace 362
isupper 362
isxdigit 363
memchr 364
memcmp 365
memcpy 366
memmove 367
memset 368
strcat 368
strchr 369
strcmp 370
strcoll 371
strcpy 372
strcspn 372
strerror 373
strlen 373
strncat 374
strncmp 375
strncpy 376
Page xiv
strpbrk 377
strrchr 377
strspn 378
strstr 379
strtok 380
strxfrm 381
tolower 381
toupper 382
15 383
Mathematical Functions
acos 386
acosh 387
asin 387
asinh 388
atan 388
atanh 389
atan2 390
cbrt 391
ceil 391
copysign 392
cos 392
cosh 393
erf 394
erfc 394
exp 395
exp2 395
expm1 395
fabs 396
fdim 397
floor 397
fma 398
fmax 398
fmin 398
fmod 399
frexp 399
hypot 400
ilogb 400
ldexp 401
lgamma 402
llrint 402
llround 402
log 403
log1p 404
Page xv
log10 404
log2 405
logb 405
lrint 406
lround 406
modf 406
nan 407
nearbyint 407
nextafter 408
nexttoward 408
pow 409
remainder 409
remquo 410
rint 410
round 411
scalbln 411
scalbn 412
sin 412
sinh 413
sqrt 414
tan 414
tanh 415
tgamma 416
trunc 416
16 417
Time, Date, and Localization Functions
asctime 418
clock 419
ctime 420
difftime 421
gmtime 422
localeconv 423
localtime 425
mktime 426
setlocale 427
strftime 428
time 431
17 433
Dynamic Allocation Functions
calloc 434
free 435
malloc 436
realloc 437
Page xvi
18 439
Utility Functions
abort 440
abs 441
assert 441
atexit 442
atof 443
atoi 444
atol 445
atoll 446
bsearch 446
div 448
exit 449
_Exit 450
getenv 450
labs 451
llabs 451
ldiv 452
lldiv 453
longjmp 453
mblen 454
mbstowcs 455
mbtowc 456
qsort 456
raise 458
rand 459
setjmp 459
signal 460
srand 460
strtod 461
strtof 463
strtol 463
strtold 464
strtoll 465
strtoul 465
strtoull 466
system 467
wcstombs 469
wctomb 470
19 471
Wide-Character Functions
20 483
Library Features Added by C99
Part IV
Algorithms and Applications
21 497
Sorting and Searching
Sorting 498
Searching 518
22 521
Queues, Stacks, Linked Lists, and Trees
Queues 522
Stacks 531
23 563
Sparse Arrays
Hashing Y 575
24 581
Expression Parsing and Evaluation
TE
Expressions 582
25 605
AI-Based Problem Solving
Team-Fly®
Search Techniques 610
Part V
Software Development Using C
26 659
Building a Windows 2000 Skeleton
WinMain( ) 664
27 679
Software Engineering Using C
28 691
Efficiency, Porting, and Debugging
Efficiency 692
Debugging 700
Part VI
A C Interpreter
29 713
A C Interpreter
Index 789