Paul S.R. Chisholm, David Hanley, Michael Jones, Michael Lindner, Lloyd Work9780672305610, 0672305615
Table of contents :
Overview……Page 5
Contents……Page 6
Introduction……Page 29
I.1: What is a local block? Answer:……Page 30
I.3: When is a switch statement better than multiple if statements? Answer:……Page 32
I.4: Is a default case necessary in a switch statement? Answer:……Page 33
I.5: Can the last case of a switch statement skip including the break? Answer:……Page 34
I.6: Other than in a for statement, when is the comma operator used? Answer:……Page 35
I.7: How can you tell whether a loop ended prematurely? Answer:……Page 36
I.8: What is the difference between goto and longjmp() and setjmp()? Answer:……Page 37
I.9: What is an lvalue? Answer:……Page 39
I.10: Can an array be an lvalue? Answer:……Page 40
I.12: Is left-to-right or right-to-left order guaranteed for operator precedence? Answer:……Page 41
I.13: What is the difference between ++var and var++? Answer:……Page 42
I.14: What does the modulus operator do? Answer:……Page 43
Variables and Data Storage……Page 44
II.2: Do variables need to be initialized? Answer:……Page 45
II.3: What is page thrashing? Answer:……Page 46
II.4: What is a const pointer? Answer:……Page 47
II.5: When should the register modifier be used? Does it really help? Answer:……Page 48
II.6: When should the volatile modifier be used? Answer:……Page 49
II.8: When should the const modifier be used? Answer:……Page 50
II.9: How reliable are floating-point comparisons? Answer:……Page 51
II.10: How can you determine the maximum value that a numeric variable can hold? Answer:……Page 52
II.11: Are there any problems with performing mathematical operations on different variable types? Answer:……Page 53
II.12: What is operator promotion? Answer:……Page 54
II.13: When should a type cast be used? Answer:……Page 55
II.15: Is it acceptable to declare/define a variable in a C header? Answer:……Page 56
II.17: Can static variables be declared in a header file? Answer:……Page 57
II.18: What is the benefit of using const for declaring constants? Answer:……Page 58
Sorting……Page 60
Searching……Page 61
Performance of Sorting or Searching……Page 62
III.1: What is the easiest sorting method to use? Answer:……Page 65
III.2: What is the quickest sorting method to use? Answer:……Page 66
III.3: How can I sort things that are too large to bring into memory? Answer:……Page 73
III.4: What is the easiest searching method to use? Answer:……Page 77
III.5: What is the quickest searching method to use? Answer:……Page 79
III.6: What is hashing? Answer:……Page 84
Sample Code……Page 86
IV.1: If errno contains a nonzero number, is there an error? Answer:……Page 92
IV.2: What is a stream? Answer:……Page 93
IV.4: How can you restore a redirected standard stream? Answer:……Page 94
IV.5: Can stdout be forced to print somewhere other than the screen? Answer:……Page 95
IV.6: What is the difference between text and binary modes? Answer:……Page 96
IV.8: How do you list files in a directory? Answer:……Page 97
IV.9: How do you list a file’s date and time? Answer:……Page 99
IV.10: How do you sort filenames in a directory? Answer:……Page 102
IV.11: How do you determine a file’s attributes? Answer:……Page 104
IV.12: How do you view the PATH? Answer:……Page 105
IV.13: How can I open a file so that other programs can update it at the same time? Answer:……Page 106
IV.15: How can I prevent another program from modifying part of a file that I am modifying? Answer:……Page 108
IV.17: How can I avoid the Abort, Retry, Fail messages? Answer:……Page 110
IV.18: How can I read and write comma-delimited text? Answer:……Page 112
Working with the Preprocessor……Page 116
V.1: What is a macro, and how do you use it? Answer:……Page 117
V.2: What will the preprocessor do for a program? Answer:……Page 119
V.3: How can you avoid including a header more than once? Answer:……Page 121
V.5: What is the benefit of using #define to declare a constant? Answer:……Page 122
V.6: What is the benefit of using enum to declare a constant? Answer:……Page 123
V.7: What is the benefit of using an enum rather than a #define constant? Answer:……Page 124
V.9: When should you use a macro rather than a function? Answer:……Page 126
V.11: What is the best way to comment out a section of code that contains comments? Answer:……Page 127
V.12: What is the difference between #include and #include “file”? Answer:……Page 128
V.14: Can include files be nested? Answer:……Page 129
V.16: What is the concatenation operator? Answer:……Page 130
V.17: How can type-insensitive macros be created? Answer:……Page 131
V.18: What are the standard predefined macros? Answer:……Page 132
V.19: How can a program be made to print the line number where an error occurs? Answer:……Page 133
V.20: How can a program be made to print the name of a source file where an error occurs? Answer:……Page 134
V.22: What is a pragma? Answer:……Page 135
V.23: What is #line used for? Answer:……Page 136
V.26: What is the _ _LINE_ _ preprocessor command? Answer:……Page 137
V.28: What are the _ _DATE_ _ and _ _TIME_ _ preprocessor commands? Answer:……Page 138
V.30: How can you be sure that a program follows the ANSI C standard? Answer:……Page 139
V.31: How do you override a defined macro? Answer:……Page 140
V.33: What common macros are available? Answer:……Page 141
VI.1: What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used? Answer:……Page 144
VI.2: How can I remove the trailing spaces from a string? Answer:……Page 146
VI.3: How can I remove the leading spaces from a string? Answer:……Page 147
VI.4: How can I right-justify a string? Answer:……Page 149
VI.5: How can I pad a string to a known length? Answer:……Page 151
VI.6: How can I copy just a portion of a string? Answer:……Page 152
VI.7: How can I convert a number to a string? Answer:……Page 153
VI.8: How can I convert a string to a number? Answer:……Page 155
VI.9: How do you print only part of a string? Answer:……Page 157
VI.11: How can you tell whether two strings are the same? Answer:……Page 158
Pointers and Memory Allocation……Page 160
VII.1: What is indirection? Answer:……Page 162
VII.2: How many levels of pointers can you have? Answer:……Page 163
VII.3: What is a null pointer? Answer:……Page 164
VII.4: When is a null pointer used? Answer:……Page 165
VII.6: When is a void pointer used? Answer:……Page 167
VII.7: Can you subtract pointers from each other? Why would you? Answer:……Page 168
VII.8: When you add a value to a pointer, what is really added? Answer:……Page 170
VII.10: Is NULL always equal to 0? Answer:……Page 171
VII.12: Can you add pointers together? Why would you? Answer:……Page 172
VII.13: How do you use a pointer to a function? Answer:……Page 173
VII.14: When would you use a pointer to a function? Answer:……Page 174
VII.15: Can the size of an array be declared at runtime? Answer:……Page 176
VII.16: Is it better to use malloc() or calloc()? Answer:……Page 178
VII.18: What is the difference between far and near? Answer:……Page 179
VII.20: What is the stack? Answer:……Page 180
VII.21: What is the heap? Answer:……Page 181
VII.22: What happens if you free a pointer twice? Answer:……Page 182
VII.24: What is a “null pointer assignment” error? What are bus errors, memory faults, and core dumps? Answer:……Page 184
VII.26: How does free() know how much memory to release? Answer:……Page 185
VII.28: How do you print an address? Answer:……Page 186
VIII.1: When should I declare a function? Answer:……Page 188
VIII.2: Why should I prototype a function? Answer:……Page 191
VIII.3: How many parameters should a function have? Answer:……Page 192
VIII.4: What is a static function? Answer:……Page 194
VIII.5: Should a function contain a return statement if it does not return a value? Answer:……Page 195
VIII.6: How can you pass an array to a function by value? Answer:……Page 196
VIII.7: Is it possible to execute code even after the program exits the main() function? Answer:……Page 198
VIII.8: What does a function declared as PASCAL do differently? Answer:……Page 199
VIII.9: Is using exit() the same as using return? Answer:……Page 200
Arrays……Page 204
IX.1: Do array subscripts always start with zero? Answer:……Page 205
IX.2: Is it valid to address one element beyond the end of an array? Answer:……Page 206
IX.3: Why worry about the addresses of the elements beyond the end of an array? Answer:……Page 207
IX.4: Can the sizeof operator be used to tell the size of an array passed to a function? Answer:……Page 208
IX.5: Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name? Answer:……Page 210
IX.6: Can you assign a different address to an array tag? Answer:……Page 212
IX.7: What is the difference between array_name and &array_name? Answer:……Page 213
IX.8: Why can’t constant values be used to define an array’s initial size? Answer:……Page 214
IX.9: What is the difference between a string and an array? Answer:……Page 215
Bits and Bytes……Page 218
X.1: What is the most efficient way to store flag values? Answer:……Page 219
X.2: What is meant by “bit masking”? Answer:……Page 220
X.4: Is it better to bitshift a value than to multiply by 2? Answer:……Page 223
X.5: What is meant by high-order and low-order bytes? Answer:……Page 224
X.6: How are 16and 32-bit numbers stored? Answer:……Page 225
XI.1: My program hangs when I run it. What should I do? Answer:……Page 226
XI.2: How can I detect memory leaks? Answer:……Page 232
XI.3: What is the best way to debug my program? Answer:……Page 233
XI.4: How can I debug a TSR program? Answer:……Page 240
XI.5: How do you get a program to tell you when (and where) a condition fails? Answer:……Page 241
Standard Library Functions……Page 244
XII.2: What header files do I need in order to define the standard library functions I use? Answer:……Page 245
XII.3: How can I write functions that take a variable number of arguments? Answer:……Page 252
XII.4: What is the difference between a free-standing and a hosted environment? Answer:……Page 254
XII.5: What standard functions are available to manipulate strings? Answer:……Page 255
XII.6: What standard functions are available to manipulate memory? Answer:……Page 258
XII.7: How do I determine whether a character is numeric, alphabetic, and so on? Answer:……Page 261
XII.9: Is there a way to jump out of a function or functions? Answer:……Page 262
XII.10: What’s a signal? What do I use signals for? Answer:……Page 264
XII.12: Why does my compiler provide two versions of malloc()? Answer:……Page 265
XII.13: What math functions are available for integers? For floating point? Answer:……Page 268
XII.14: What are multibyte characters? Answer:……Page 269
XII.15: How can I manipulate strings of multibyte characters? Answer:……Page 270
XIII.1: How can I store a date in a single number? Are there any standards for this? Answer:……Page 272
XIII.2: How can I store time as a single integer? Are there any standards for this? Answer:……Page 277
XIII.3: Why are so many different time standards defined? Answer:……Page 280
XIII.5: What is the best way to store the time? Answer:……Page 281
System Calls……Page 284
XIV.1: How can environment variable values be retrieved? Answer:……Page 285
XIV.2: How can I call DOS functions from my program? Answer:……Page 286
XIV.3: How can I call BIOS functions from my program? Answer:……Page 287
XIV.4: How can I access important DOS memory locations from my program? Answer:……Page 289
XIV.5: What is BIOS? Answer:……Page 291
XIV.6: What are interrupts? Answer:……Page 292
XIV.7: Which method is better, ANSI functions or BIOS functions? Answer:……Page 293
XIV.8: Can you change to a VGA graphics mode using the BIOS? Answer:……Page 294
XIV.9: Does operator precedence always work (left to right, right to left)? Answer:……Page 298
XIV.11: Should programs always include a prototype for main()? Answer:……Page 300
XIV.13: Can I control the mouse using the BIOS? Answer:……Page 301
Portability……Page 304
XV.2: What is the difference between C++ and C? Answer:……Page 306
XV.4: How big is a char? A short ? An int? A long? Answer:……Page 308
XV.5: What’s the difference between big-endian and little-endian machines? Answer:……Page 309
ANSI/ISO Standards……Page 312
XVI.1: Does operator precedence always work? Answer:……Page 313
XVI.2: Should function arguments’ types be declared in the argument list of a function or immediately following? Answer:……Page 317
XVI.3: Should programs include a prototype for main()? Answer:……Page 318
XVI.4: Should main() always return a value? Answer:……Page 319
XVII.1: Why don’t I see my screen output until the program ends? Answer:……Page 322
XVII.2: How do I position the cursor on the screen? Answer:……Page 323
XVII.3: What is the easiest way to write data to the screen? Answer:……Page 324
XVII.4: What is the fastest way to write text to the screen? Answer:……Page 325
XVII.5: How can I prevent the user from breaking my program with Ctrl-Break? Answer:……Page 329
XVII.7: Why shouldn’t scanf be used to accept data? Answer:……Page 331
XVII.8: How do I use function keys and arrow keys in my programs? Answer:……Page 333
XVII.9: How do I prevent the user from typing too many characters in a field? Answer:……Page 334
XVII.11: How do you print a dollars-and-cents value? Answer:……Page 336
XVII.13: What is the ANSI driver? Answer:……Page 339
XVII.15: How do you save the cursor’s position with the ANSI driver? Answer:……Page 340
XVII.18: How do you write text in color with the ANSI driver? Answer:……Page 341
XVII.19: How do I move the cursor with the ANSI driver? Answer:……Page 342
Writing and Compiling Your Programs……Page 344
XVIII.1: Should my program be written in one source file or several source files? Answer:……Page 345
XVIII.3: What are the most commonly used memory models? Answer:……Page 346
XVIII.4: Which memory model should be used? Answer:……Page 347
XVIII.6: What is the benefit of a .COM file over an .EXE file? Answer:……Page 348
XVIII.7: Are all the functions in a library added to an .EXE file when the library is linked to the objects? Answer:……Page 349
XVIII.9: Why should I create a library? Answer:……Page 350
XVIII.10: My program has several files in it. How do I keep them all straight? Answer:……Page 351
XVIII.11: I get the message DGROUP: group exceeds 64K during my link. What’s wrong? Answer:……Page 352
XVIII.13: My program is too big to run under DOS. How can I make it fit? Answer:……Page 353
XVIII.14: How can I get more than 640KB of memory available to my DOS program? Answer:……Page 354
XVIII.15: What is the difference between near and far? Answer:……Page 356
Programming Style and Standards……Page 360
XIX.2: Can a variable’s name be used to indicate its data type? Answer:……Page 361
XIX.3: Does the use of comments affect program speed, executable size, or efficiency? Answer:……Page 362
XIX.4: Does the use of white space affect program speed, executable size, or efficiency? Answer:……Page 363
XIX.6: Do longer variable names affect the speed, executable size, or efficiency of a program? Answer:……Page 365
XIX.7: What is the correct way to name a function? Answer:……Page 366
XIX.8: What is the correct way to use braces? Answer:……Page 367
XIX.9: How many letters long should variable names be? What is the ANSI standard for significance? Answer:……Page 368
XIX.10: What is Hungarian notation, and should I use it? Answer:……Page 369
XIX.11: What is iterative processing? Answer:……Page 370
XIX.12: What is recursion, and how do you use it? Answer:……Page 371
XIX.13: What is the best way to represent true and false in C? Answer:……Page 373
XIX.14: What is the difference between a null loop and an infinite loop? Answer:……Page 374
XIX.15: What is the difference between continue and break? Answer:……Page 375
XX.1: How are command-line parameters obtained? Answer:……Page 378
XX.2: Should programs always assume that command-line parameters can be used? Answer:……Page 380
XX.3: What is the difference between “exception handling” and “structured exception handling”? Answer:……Page 381
XX.5: Who are Kernighan and Ritchie? Answer:……Page 382
XX.6: How do you create random numbers? Answer:……Page 383
XX.7: When should a 32-bit compiler be used? Answer:……Page 385
XX.8: How do you interrupt a Windows program? Answer:……Page 386
XX.9: Why should I use static variables? Answer:……Page 389
XX.10: How can I run another program after mine? Answer:……Page 390
XX.11: How can I run another program during my program’s execution? Answer:……Page 391
XX.12: How can I pass data from one program to another? Answer:……Page 392
XX.13: How can I determine which directory my program is running from? Answer:……Page 397
XX.14: How can I locate my program’s important files (databases, configuration files, and such)? Answer:……Page 398
XX.16: How do you disable Ctrl-Break? Answer:……Page 399
XX.17: Can you disable warm boots (Ctrl-Alt-Delete)? Answer:……Page 401
XX.18: How do you tell whether a character is a letter of the alphabet? Answer:……Page 403
XX.19: How do you tell whether a character is a number? Answer:……Page 404
XX.20: How do you assign a hexadecimal value to a variable? Answer:……Page 405
XX.22: What is binary? Answer:……Page 406
XX.23: What is octal? Answer:……Page 408
XX.24: What is hexadecimal? Answer:……Page 409
XX.25: What are escape characters? Answer:……Page 411
Windows……Page 414
XXI.1: Can printf() be used in a Windows program? Answer:……Page 415
XXI.3: What is a handle? Answer:……Page 416
XXI.4: How do you interrupt a Windows program? Answer:……Page 417
XXI.5: What is the GDI and how is it accessed? Answer:……Page 418
XXI.6: Why is windows.h important? Answer:……Page 419
XXI.7: What is the Windows SDK? Answer:……Page 420
XXI.9: What is the difference between Windows functions and standard DOS functions? Answer:……Page 421
XXI.10: What is dynamic linking? Answer:……Page 422
XXI.12: Are Windows programs compatible from one compiler to the next? Answer:……Page 423
XXI.13: Will Windows always save and refresh your program’s windows? Answer:……Page 424
XXI.14: How do you determine a Windows program’s client area size? Answer:……Page 425
XXI.16: Should a Windows program care about the OEM key codes? Answer:……Page 426
XXI.17: What are virtual key codes? Answer:……Page 427
XXI.18: What is a dead key? Answer:……Page 429
XXI.19: What is the difference between the caret and the cursor? Answer:……Page 430
XXI.20: Can a mouse click be captured in an area outside your program’s client area? Answer:……Page 431
XXI.21: How do you create an animated bitmap? Answer:……Page 432
XXI.22: How do you get the date and time in a Windows program? Answer:……Page 433
XXI.24: How do you access the system colors in a Windows program? Answer:……Page 434
XXI.25: What are the system color constants? Answer:……Page 435
XXI.26: How do you create your own buttons or controls? Answer:……Page 436
XXI.27: What is a static child window? Answer:……Page 437
XXI.28: What is window subclassing? Answer:……Page 438
XXI.29: What is the edit class? Answer:……Page 439
XXI.30: What is the listbox class? Answer:……Page 440
XXI.31: How is memory organized in Windows? Answer:……Page 441
XXI.32: How is memory allocated in a Windows program? Answer:……Page 442
XXI.33: What is the difference between modal and modeless dialog boxes? Answer:……Page 443
Index……Page 444
Standard library functions header files……Page 460
Reviews
There are no reviews yet.