Sams Teach Yourself C in 24 Hours (77 page)

closing files,

comparison, 381,

fseek() function

358-360, 371

388

code example, 375-378

code example,

syntax, 382

random access, 374-378

359-360

fputc()

syntax, 374

syntax, 359

code example,

ftell() function

feof(), 367

361-363

code example, 375-378

code example,

syntax, 361

random access, 374-378

368-369

writing files,

syntax, 375

syntax, 367

360-363

function scope (vari-

fgetc()

fputs()

ables), 226-227

code example,

code example,

functions, 46, 432-433.

361-363

364-366

See also
statements

reading files,

puts() function com-

arrays, passing,

360-363

parison, 364

266-267, 270-272

syntax, 361

syntax, 364

asctime(), 250-251

fgets()

writing files,

beginning, 48

code example,

363-366

BlockReadWrite(), 369

364-366

fread()

body, 48-49

gets() function com-

binary files, 381

calling, 49-51, 245-249

parison, 364-366,

code example,

calloc(), 286-288

371

368-369

CharReadWrite(),

reading files,

reading files,

362-363

363-366

366-369

complexity, 49

reading keyboard

syntax, 366

Convert2Upper(), 303

input, 366

free(), 283-286

cos(), 149-150

syntax, 363

freopen()

DataDisplay(), 326, 346

fopen(), 381

code example,

DataEnter(), 346

code example,

385-386

DataRead(), 377, 381,

359-360

modes, 385-386

384

formatting new files,

redirecting streams,

DataReceive(), 321

388

384-388

DataWrite(), 381, 384

modes, 357-358, 388

syntax, 384

date and time, 249

opening files,

fscanf()

declaring, 244-247, 432

357-358

code example,

prototypes, 245

syntax, 357

382-384

specifying return

scanf() function

types, 244

comparison, 381

void data type,

syntax, 381

248-249

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

514

functions

fseek()

printf(), 78-79, 217, 386

strlen(), 212-213

code example,

format specifiers,

StrPrint, 386

375-378

78-79

structures, passing,

random access,

fprintf() function

319-321

374-378

comparison, 381,

tan(), 149-150

syntax, 374

388

time(), 250

ftell()

prototyping, 245-247,

types, 46-47

code example,

432

variable declarations,

375-378

fixed number of

48

random access,

arguments, 251

va_end(), 252

374-378

no arguments,

fwrite() function

syntax, 375

248-249

binary files, 381

fwrite()

variable number of

code example, 368-369

binary files, 381

arguments, 251-252

files, writing, 366-369

code example,

PtrSeek(), 377

syntax, 367

368-369

PtrTell(), 377

syntax, 367

putc(), 75-76

writing files,

putchar(), 77-78

366-369

puts()

G

getc(), 72-74

fputs() function com-

getchar(), 74-75,

parison, 364

%g format specifier, 79

248-249

syntax, 215

getc() function, 72-74

gets()

realloc(), 288-291

getchar() function, 74-75,

fgets() function com-

recursive, 303-305

248-249

parison, 364-366,

calling, 303-304

gets() function, 215-217,

371

fRecur(), 304

364-366, 371

syntax, 215

running, 305

global variables, 227, 233

InfoDisplay(), 329

rewind(), 378

declaring, 229

InfoEnter(), 329

code example,

versus local, 418

LineReadWrite(), 365

379-384

goto statement, 56, 155,

localtime(), 250

syntax, 378

168-169, 419

longjmp(), 440

scanf(), 217-219

avoiding, 168

low-level I/O, 387

fscanf() function

labels, location, 169

main(), 29, 33, 305-306

comparison, 381

spaghetti code, 169

malloc(), 280-283, 292

syntax, 217

greater than operator

naming, 47, 418

setbuf(), 387

(>), 98

passing arguments to,

setjmp(), 440

greater than or equal to

47-48

setlocale(), 440

operator (>=), 98

pointers to

setvbuf(), 387

grouping variables with

declaring, 274-275

sin(), 149-150

structures, 314

passing, 268-270

sqrt(), 150-152

groups, 314

pow(), 150-152

strcpy(), 213-215, 336

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

input, user

515

H

writing output, 75

#include directive, 31

printf() function,

increasing program

78-79

portability, 234

h

putc() function,

increment operator (++),

adding to fprintf format

75-76

96-98

specifiers, 147-148

putchar() function,

indentation (in code), 28,

adding to printf format

77-78

419

specifiers, 147-148

IDE (integrated develop-

indexes (arrays), 190

hardware requirements,

ment environment)

indirection operator.
See

16

Borland C++, 21

deference operator

header files, 32

Visual C++, 18

infinite loops, 166-167

ANSI, 439

identifiers, 44

InfoDisplay() function,

stddef.h, 301

#if directive, 434

329

stdio.h, 32

arithmetic expressions,

InfoEnter() function, 329

gets() function, 215

406

information hiding (mod-

puts() function, 215

code example, 401-402

ular programming), 419

stdlib.h, 302

macro definitions, 400

initializers, 317

string.h, 302

nested conditional com-

initializing

hex numbers, converting

pilation, 402-404

array elements, 191

decimal numbers to,

syntax, 399

character arrays,

79-81, 129-130

if statement, 56, 155-158

208-211

high-level I/O, 357, 433

braces, 156

elements, 192

high-level programming

codes, executing, 156

multidimensional

languages, 12-14

conditions, evaluating,

arrays, 199-201

history of C, 12

156

multidimensional

listing, 157

unsized arrays,

nesting, 160-161

202-203

I

if-else statement, 155,

strings, 208-211

158-159

structures, 317-319

#ifdef directive, 397, 434

unions, 337-339, 351

%i (integer) format spec-

code example, 398-399

memory sharing

ifier, 79

syntax, 397

code example,

I/O, 433-434

#ifndef directive,

338-339

buffered, 433

397-399, 416

structures, 338

high-level, 433

code example, 398-399

unsized character

streams, 72

syntax, 398

arrays, 209

user input, 72

illegal characters (identi-

input data, reading,

getc() function,

fiers), 44

217-219

72-74

implementing algo-

input/output.
See
I/O

getchar() function,

rithms, 305

input, user, 72

74-75

improving readability, C

getc() function, 72-74

programs, 296, 300

getchar() function,

74-75

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

516

int data type

int data type, 46, 62

const, 56

labels

int keyword, 56

continue, 56

conditional branching

integer constants, 422

default, 56

statements, 162

integer format specifiers

do, 56

location, goto state-

%d, 63-64, 79

double, 56

ment, 169

%i, 79

else, 56

languages.
See
program-

integer values

enum, 56

ming languages

default, 296

extern, 56

left values, 176

enum data types,

float, 56

defined, 187

assigning, 296, 300

for, 56

obtaining, 178

integers

goto, 56

left-hand operands, 92

adding, 304

if, 56

left-justifying output,

arrays, 190

int, 56

83-84

declaring, 62-63

list of, 420-421

left-shift operator (<<),

negatives, 95

long, 56

133-135

pointers, 259

register, 56, 233

legal characters (identi-

structures, assigning,

reserved, 45

fiers), 44

315

return, 56

lengths of strings, mea-

integrated development

short, 56

suring, 212-213

environment.
See
IDE

signed, 56

less than operator (<), 98

interpreted programming

sizeof, 56

less than or equal to

languages, 15

static, 56

operator (<=), 98

interpreters.
See
compil-

struct, 56, , 348-350

levels (programming lan-

ers

switch, 56

guages), 12

iteration.
See
loops

typedef, 57, 300-301,

libraries, 14

321, 426

limits.h header file, 439

union, 57

line numbers, 28

unsigned, 57

LineReadWrite() func-

J-K

void, 57, 305

tion, 365

volatile, 57

lines (code)

jumping statements.
See

while, 57

breaking, 28

conditional branching

indenting, 28

statements

linked lists, 410

justifying.
See
aligning

advantages, 410

L

creating, 410

”K & R”, 15

adding nodes, 414

keyboards, input, 366

l

calling functions in

keywords, 56

adding to fprintf format

module file,

auto, 56

specifiers, 147-148

416-418

break, 56

adding to printf format

header file, 415-416

case, 56, 162

specifiers, 147-148

module program

char, 56

example, 410-415

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

listings

517

linkers, 34-36

declaring and assigning

gets() function, 216

listings

pointer values, 180

%hd, %lu, and %ld for-

accessing arrays via

#define directive,

mat specifiers,

pointers, 264-265

394-395

147-148

adding integers with a

defining enum data

hex numbers, convert-

function, 49

types, 297

ing to, 80

aligning output, 83

do-while loop example,

#if directive, 401

arithmetic assignment

108

if statement in decision

operators, 94

#elif directive, 401

making, 157

arrays of structures,

#else directive, 401

if-else statement, 159

325-326

#endif directive, 398

#ifdef directive, 398

binary files,

ending output at null

#ifndef directive, 398

reading/writing,

character, 198

increment and decre-

379-380

enum data types,

ment operators, 97

bit fields, 348-349

298-299

Other books

The Trials of Renegade X by Chelsea M. Campbell
Someone Like You by Susan Mallery
In Close by Brenda Novak
The Inseparables by Stuart Nadler


readsbookonline.com Copyright 2016 - 2024