Sams Teach Yourself C in 24 Hours (75 page)

BOOK: Sams Teach Yourself C in 24 Hours
8.76Mb size Format: txt, pdf, ePub
ads

bit fields

multidimensional

values

code example, 348-350

declaring, 199

to enum data types,

declaring, 347

displaying, 200-201

299

defining, 347

initializing, 199-201

to pointers, 180-181

bit-manipulation opera-

multidimensional

assignment operator (=),

tors, 130

unsized

92

bitwise AND (&), 131

declaring, 201

asterisks (*)

bitwise complement

initializing, 202-203

deference operator, 182

(~), 131

listing, 325-326

determining meaning,

bitwise OR (|), 131

passing to functions,

182

bitwise XOR (^), 131

266-267, 270-272

multiplication operator,

left-shift (<<), 133-135

pointers

182

right-shift (>>),

declaring, 272

pointers, 180

133-135

referencing with,

auto keyword, 56

bits, 14, 58, 142

195-196

auto specifier, variables,

bitwise AND operator

strings, 272-274

229

(&), 131

sizes

avoiding

bitwise complement

calculating, 192-194

duplication, structures,

operator (~), 131

specifying, 267

322

bitwise OR operator (|),

of structures, 324-327

goto statements, 168

131

unsized

bitwise XOR operator

calculating, 201

(^), 131

versus structures,

block scope (variables),

314

B

224-225

unsized character, 209

local variables, 225

arrow (->) operators,

\b (backspace character),

nested, 225-226

324, 335, 351

60

program scope compar-

ASCII character codes,

backslash.
See
escape

ison, 227-229

57

character

BlockReadWrite() func-

asctime() function,

big-endian format, 343

tion, 369

250-251

binary code, 14, 24

blocks

assert.h header file, 439

binary files

commenting out, 31

assessing structure mem-

reading, 378-381

statement, 45-46

bers, 315

writing, 378-381

body, functions, 48-49

assigning

binary format, 13

books (recommended

character constants to

binary numbers

reading), 434-435

pointers, 210

converting decimal

character strings to

numbers to, 129-130

pointers, 210-211

negatives, 142

34 067231861x index 1/25/00 10:45 AM Page 506

506

Borland C++ compiler

Borland C++ compiler,

C

#if directive, 434

21-24

arithmetic expres-

running, 23

sions, 406

%c (character) format

starting, 21

code example,

specifier, 60-62, 74, 79

bottom-up programming,

401-402

.c filename extension, 28

255

macro definitions,

C

braces ({}), 45, 48

400

advantages, 12-14

if statement, 156

nested conditional

history, 12

if-else statement, 159

compilation,

portability, 13

switch statement, 165

402-404

programs

brackets ([ ]), declaring

syntax, 399

maintaining, 296

arrays, 190

#ifdef directive,

readability, improv-

break keyword, 56

397-399, 434

ing, 296, 300

break statements, 155,

#ifndef directive,

structured program-

164-165

397-399, 416

ming, 169

infinite loops, breaking,

macro body, 392, 396

C compiler, C preproces-

166-167

macro names, 392-393

sor comparison, 392-

listing, 164-165

macro substitution,

393, 405

location, 164

392-396

C preprocessor, 392

switch statements, exit-

newline characters, 392

# (pound sign), 392

ing, 164

#undef directive,

C compiler comparison,

breaking code lines, 28

393-394, 406, 434

392-393, 405

buffered I/O, 433

C Programming

#define directive, 393,

buffers, 356

Language, The
, 15

434

flushing, 356

C++, 14

code example,

high-level I/O, 357

calculating array size,

394-396

low-level I/O, 357, 387

192-194, 201

defining function-

setbuf() functions, 387

calendar time, date and

like macros,

setvbuf() functions, 387

time functions, 249

394-396

bugs.
See
debugging

calling

expressions, 396

built-in arguments

functions, 49-51,

nested macro defini-

main() functions, 306

245-247

tions, 396

naming, 308

no arguments, 249

syntax, 393

replacing, 308

recursive, 303-304

#elif directive, 401-402,

bytes, 14, 58, 192-194

calloc() function, 286-288

434

listing, 287

#else directive,

malloc() functions,

399-402, 434

compared, 292

#endif directive,

case keyword, 56, 162

397-402, 406, 416

case sensitivity, file-

code example,

names, 32

398-399

syntax, 397

34 067231861x index 1/25/00 10:45 AM Page 507

conditional compilation

507

cast operator, 101-102

writing

command-line argu-

central processing unit

from standard output

ments, 305

(CPU), 13

stream, 217

listing, 306-307

changing variable values

puts() function,

number, checking, 307

via pointers, 183-184

215-217

receiving, 306-308

char data type, 47, 57

to standard output

comments, 29-31, 418

char keyword, 56

stream, 215-216

commenting out code,

character arrays.
See

CharReadWrite() func-

31

also
strings

tion, 362-363

nested, 31

initializing, 208-209

checking command-line

program performance,

string constants, initial-

arguments, 307

30

izing, 208-211

classes, storage, 229

compiled languages, 14-

unsized, 209

closing files, fclose() func-

15

character codes (ACII),

tion, 358-360, 371

compilers, 13

57

closing comment mark

accessing, 17

character constants,

(*/), 29

Borland C++, 21-24

58-59, 422-423

code, 14.
See also
listings

C, C preprocessor com-

pointers, assigning, 210

binary, 14

parison, 392-393, 405

string constants, com-

breaking lines, 28

choosing, 17

pared, 209-212

comments, 29-31, 418

compliancy errors,

character data type.
See

commenting out, 31

280-281

char data type

nested, 31

Microsoft, 18-21

character format specifi-

performance, 30

optimizers, turning off,

er (%c), 60-62, 74, 79

indentation, 28, 419

235

character strings, 196,

saving

compliancy error,

210-211

Borland C++, 23

280-281

character variables, 58

Visual C++, 19

conditional branching

characters

source code file, 34

statements, 155,

arrays, 190, 196-198

spacing, 419

428-430

converting numeric val-

spaghetti, 169

break, 155, 164-165

ues to, 61

syntax, checking, 36

continue, 155, 167-168

null, 198.
See also

whitespace, 29

goto, 155, 168-169

strings

writing

if, 155-158

numeric values

Borland C++, 21

if-else, 155, 158-159

converting, 61

Visual C++, 18

labels, 162

showing, 63-64

codes, executing if state-

switch, 155, 161-164

printing, 60-62

ment, 156

conditional compilation,

reading

coding style, 418-419

397

from standard input

collecting variables,

#elif directive, 401-402

stream, 215-217

groups, 314

#else directive, 399-402

gets() function,

combining declarations

215-217

and definitions, 315

34 067231861x index 1/25/00 10:45 AM Page 508

508

conditional compilation

#endif directive,

numeric, versus named,

creating

397-402, 406

419

declarations, 299

code example,

string, 209-212, 423

expressions, 299

398-399

content, memory, 177

names for data types,

syntax, 397

continue keyword, 56

300-302

#if directive

continue statement, 155,

ctype.h header file, 439

arithmetic expres-

167-168

sions, 406

listing, 167

code example,

loops, 167, 171

401-402

control flow, 426

D

macro definitions,

conditional branching

400

statements, 155,

%d (integer) format

nested conditional

428-430

specifier, 63-64, 79

compilation,

break, 164-165

data

402-404

continue, 167-168

formatted

syntax, 399

goto, 168-169, 419

fprintf() function,

#ifdef directive,

if, 156-158

381-384, 388

397-399

if-else, 158-159

fscanf() function,

#ifndef directive,

switch, 161-164

381-384

397-399

looping statements,

stack, overwriting, 305

conditional expressions,

155, 427-428

data items, separating,

switch statement,

Convert2Upper() func-

317

161-162

tion, 303

data modifiers

conditional operator (:?),

converting

long, 145-147

135-136

data types, cast opera-

short, 145

conditions, evaluating (if

tor, 101-102

signed, 142-143

statement), 156

dates, asctime() func-

unsigned, 143-145

consolidating data types,

tion, 250-251

data structures, linked

300

numbers

lists, 410

const keyword, 56

decimal to binary,

advantages, 410

const modifier (vari-

129-130

creating, 410-418

ables), 234-235

decimal to hex,

data types, 423.
See also

constants, 42

129-130

variables

character, 58-59,

time, asctime() func-

array, 424

209-212, 422-423

tion, 250-251

char, 47, 57

EOF (end-of-file), 73

to uppercase, 302-303

consolidating, 300

floating-point, 423

copying strings, 213-215

converting, cast opera-

integer, 422

cos() function, 149-150

tor, 101-102

macro body, 392

CPU (central processing

creating, 426

named, versus numeric,

unit) register, 233

defining, variable lists,

419

CPUs (central processing

424

named integer, declar-

units), 13

double, 67

ing, 296

34 067231861x index 1/25/00 10:45 AM Page 509

defining

509

enum, 296, 424

decisions, unlimited

decrement operator (--),

declaring, 296

(switch statements), 161

96-98

defining variables,

BOOK: Sams Teach Yourself C in 24 Hours
8.76Mb size Format: txt, pdf, ePub
ads

Other books

The Duke's Temptation by Addie Jo Ryleigh
I Drink for a Reason by David Cross
More With You by Ryan, Kaylee
Dead Water by Victoria Houston
Symbiography by William Hjortsberg
Unknown by Unknown
Marrying Off Mother by Gerald Durrell