Read without ads and support Scribd by becoming a Scribd Premium Reader.
 
Beej's Guide to C Programming
Brian “Beej” Hallbeej@beej.us
Revision alpha-25May 17, 2007
Copyright © 2007 Brian “Beej” Hall
 
ii
Contents
1. Foreward...................................................................................................................................1
1.1. Audience11.2. Platformand Compiler11.3. Building under Unix21.4. Official Homepage21.5. Email Policy21.6. Mirroring21.7. Note for Translators21.8. Copyright and Distribution3
2. ProgrammingBuilding Blocks................................................................................................4
2.1. TheSpecification42.2. The Implementation52.3. So MuchTo Do, So Little Time62.4. Hello, World!7
3. Variables, Expressions, and Statements (Oh My)..............................................................10
3.1. Variables103.2. Operators113.3. Expressions123.4. Statements12
4. Building Blocks Revisited......................................................................................................175. Functions.................................................................................................................................18
5.1. Passing by Value195.2. Function Prototypes20
6. Variables, The Sequel............................................................................................................22
6.1. “Up Scope”226.2. StorageClasses24
7. Pointers--Cower In Fear!......................................................................................................26
7.1. Memory and Variables267.2. Pointer Types277.3. Dereferencing287.4. PassingPointers as Parameters28
8. Structures................................................................................................................................30
8.1. Pointers to
s308.2. Passing
struct
pointers to functions32
9. Arrays......................................................................................................................................33
9.1. Passingarrays to functions34
10. Strings....................................................................................................................................3711. Dynamic Memory.................................................................................................................39
11.1.
 malloc()
39
 
Contents 
iii
11.2.
free()
4011.3.
realloc()
4011.4.
calloc()
41
12. More Stuff!............................................................................................................................43
12.1. PointerArithmetic4312.2. typedef4412.3.
enum
4512.4. More
struct
declarations4612.5. Command Line Arguments4612.6. Multidimensional Arrays4912.7. Castingand promotion5012.8. Incomplete types5112.9.
void
pointers5112.10.
NULL
 pointers5312.11. MoreStatic5312.12. Typical Multifile Projects5412.13. The Almighty C Preprocessor5612.14. Pointers to pointers5912.15. Pointers to Functions6112.16. Variable Argument Lists63
13. Standard I/OLibrary..........................................................................................................67
13.1.
fopen()
6913.2.
freopen()
7113.3.
fclose()
7313.4.
 printf()
,
7413.5.
scanf()
,
7813.6.
gets()
,
8113.7.
getc()
,
,
getchar()
8313.8.
 puts()
,
8413.9.
 putc()
,
,
 putchar()
8513.10.
,
8613.11.
ftell()
8813.12.
fgetpos()
,
8913.13.
ungetc()
9013.14.
fread()
9213.15.
fwrite()
9413.16.
feof()
,
,
9513.17.
 perror()
9613.18.
remove()
9813.19.
renam e()
9913.20.
tmpfile()
10013.21.
tmpna m()
10113.22.
setbuf()
,
10313.23.
fflush()
105
14. String Manipulation...........................................................................................................107
14.1.
strlen()
10814.2.
strcmp()
,
109
Search History:
Searching...
Result 00 of 00
00 results for result for
  • p.
  • Notes
    Load more