Dan Gookin

Dan Gookin

Dan Gookin has been writing about technology for 20 years. He has contributed articles to numerous high-tech magazines and written more than 90 books about personal computing technology, many of them accurate. He combines his love of writing with his interest in technology to create books that are informative and entertaining, but not boring. Having sold more than 14 million titles translated into more than 30 languages, Dan can attest that his method of crafting computer tomes does seem to work. Perhaps Dan’s most famous title is the original DOS For Dummies, published in 1991. It became the world’s fastest-selling computer book, at one time moving more copies per week than the New York Times number-one best seller (although, because it’s a reference book, it could not be listed on the NYT best seller list). That book spawned the entire line of For Dummies books, which remains a publishing phenomenon to this day. Dan’s most recent titles include PCs For Dummies, 9th Edition; Buying a Computer For Dummies, 2005 Edition; Troubleshooting Your PC For Dummies; Dan Gookin’s Naked Windows XP; and Dan Gookin’s Naked Office. He publishes a free weekly computer newsletter, “Weekly Wambooli Salad,” and also maintains the vast and helpful Web site www.wambooli.com.

Articles From Dan Gookin

page 1
page 2
page 3
page 4
page 5
page 6
page 7
page 8
page 9
page 10
page 11
page 12
page 13
page 14
page 15
page 16
page 17
page 18
page 19
page 20
page 21
page 22
page 23
page 24
page 25
page 26
page 27
page 28
page 29
page 30
page 31
page 32
page 33
page 34
page 35
page 36
page 37
page 38
page 39
page 40
page 41
page 42
page 43
page 44
page 45
page 46
page 47
page 48
page 49
page 50
page 51
page 52
page 53
page 54
page 55
page 56
page 57
page 58
page 59
page 60
page 61
page 62
page 63
page 64
page 65
page 66
page 67
page 68
page 69
page 70
page 71
page 72
page 73
722 results
722 results
How to Restore a System Image on Your Windows PC

Article / Updated 08-16-2022

The only time you need to restore a system image on your Windows PC is when the entire hard drive is dead, missing, or replaced with a cheese sandwich. With all that data gone, you have to rely upon three items: A recovery volume: Use this media to start the PC and access the Windows Recovery Environment. The tools presented help you navigate through recovery. The system image: Use this information to restore Windows and other partitions as a base to rebuild your computer system. Tools on the recovery volume help you use the system image information. File History: Finally, with Windows restored, you run the File History program to recover your PC's lost files and programs. You don't need to restore a system image if you merely need to recover from a Windows disaster. The first thing you should try is System Restore. Second, you can try to reset the PC. Otherwise, the process of using the system image works like this: Start the PC by using the Windows Recovery Environment. Choose Troubleshoot. Choose Advanced Options. Choose System Image Recovery. Point the system image recovery tool at the location of the system image files, and then sit back and wait as the system is rebuilt. Yes, the process is more complex than four simple steps. For example, you may need a replacement hard drive. The good news is that you have the system image if you need it. Along with a recent backup, you can fully restore your system no matter what happens to the computer.

View Article
10 Common Mistakes in C Programming

Article / Updated 08-04-2022

The programming adventure has its pitfalls and most C programmers can’t claim to be free of some mistakes. Many of them are common; the same mistakes, over and over. Even after decades of coding, C programmers often still find themselves doing stupid, silly things. Most often they’re done in haste — usually, simple things. But isn’t that the way of everything? Conditional Foul-Ups When you employ an if statement or initiate a while or for loop, the code makes a comparison. Properly expressing this comparison is an art form, especially when you try to do multiple things at once. My advice is to first split up the code before you load everything into the parentheses. For example: while((c=fgetc(dumpme)) != EOF) The code on the preceding line works, but before you get there, try this: c = 1; /* initialize c */ while(c != EOF) c=fgetc(dumpme); This improvement is more readable and less error prone. The situation grows more hair when you use logical operators to combine conditions. It’s highly recommended that you limit the expression to two choices only: if( a==b || a==c) The statements belonging to if are executed when the value of variable a is equal to either the value of variable b or variable c. Simple. But what about this: if( a==b || a==c && a==d) Oops. Now the order of precedence takes over, and for the if statement to be true, a must be equal to b, or a must be equal to both c and d. The situation can also be improved by using parentheses: if( a==b || (a==c && a==d)) When you’re unsure about the order of precedence, use parentheses. == v. = A single equal sign is the assignment operator: a=65; A double equal sign is used for comparison: a==65 To get your brain to appreciate the difference, in your head you can say “is equal to” when you type two equal signs. Despite this reminder, it’s still easy to goof up, especially in a conditional statement. When you assign a value in a conditional statement, you generally create a TRUE condition unless the result of the assignment is zero: if(here=there) This if statement evaluates to the value of variable there. If it’s 0, the if condition evaluates as FALSE; otherwise, it’s true. Regardless, it’s most likely not what you intended. Most compilers, such as clang, catch this mistake. Dangerous loop semicolons in your C code You can get into a rut when you’re typing code, using the semicolon as a prefix before typing the Enter key to end a line. This practice has unintended consequences! It’s especially toxic when you code loops: for(x=0;x<10;x++); This loop works, but its statements aren’t repeated. When it’s done, the value of variable x is 10. That’s it. The same problem exists for a while loop: while(c<255); This loop may spin endlessly, depending on the value of variable c. If the value is greater than or equal to 255, the loop won’t execute. Otherwise, it executes forever. These semicolons are unintentional and unwanted. They’re also perfectly legitimate; the compiler doesn’t flag them as errors, though you may see a warning — which is quite helpful. For example, the suggested resolution is to place the semicolon on the next line: while(putchar(*(ps++))) ; This sole semicolon on a line by itself shouts to the compiler, as well as to any programmer reading the code, that the while loop is intentionally empty. Commas in a C for loop The three items in a for loop’s parentheses are separated by semicolons. Both those semicolons are required, and they are not commas. The compiler doesn’t like this statement: for(a=0,a<10,a++) Because commas are allowed in a for statement, the compiler merely thinks that you’ve omitted the last two required items. In fact, the following is a legitimate for statement: The preceding statement assigns the value 0 to variable a, generates a TRUE comparison (which is ignored), and increments the value of a to 1. Then, because the second and third items are empty, the loop repeats endlessly. (Well, unless a break statement belongs to the loop.) Missing break in a switch structure It’s perfectly legitimate to write a switch structure where the execution falls through from one case statement to the other: In this example, the first five case conditions capture the same set of statements. When you forget the break, however, execution falls through with more tests and, eventually, the default. Unless this control is what you want, remember to add break statements as necessary. Suppose that you have a switch structure that’s several dozen lines high. One case condition has multiple rows of statements, so many that it scrolls up and off the screen. In such a setup, it’s easy to forget the break as you concentrate instead on crafting the proper statements. I know — I’ve done it. Another situation happens when you code a loop inside a switch structure and you use break to get out of that loop. This inner break escapes from the for loop, only: A second break is required in order to get out of the switch structure. Many editors, such as the one used in Code::Blocks, let you collapse and expand parts of your code. To make this feature work in a switch structure, you must enclose the case statements in curly brackets. Missing parentheses and curly brackets in your C code Forgetting a parenthesis or two is one of the most common C coding mistakes. The compiler catches it, but usually the error isn’t flagged until the end of the function. For example, a missing parenthesis in the main() function causes the error to be flagged at the final line of the function. This warning is a good clue to a missing parenthesis or curly bracket, but it doesn’t help you locate it. Today’s editors are good at matching up parentheses and brackets. For example, the Code::Blocks editor inserts both characters when you type the first one. This feature helps keep things organized. Other editors, such as vim, highlight both sets of brackets when the cursor hovers over one. Use these hints as you type to ensure that things match up. Another editor clue is that the formatting, text coloring, and indents screw up when you forget a parenthesis or bracket. The problem with recognizing this reminder is that the human brain automatically assumes that the editor has screwed up. So you need to train yourself to recognize improper indentation by the editor as a sign of a missing parenthesis or curly bracket. Don’t ignore a warning from your C program When the compiler generates a warning, the program (or object code) is still created. This condition can be dangerous, especially when dealing with pointer errors. The problem is that warnings can be ignored; the code compiles anyway. For example, you may be using printf() to display a value that you know is an int, but somehow the compiler insists that it’s some other value. If so, you can typecast the variable as an int. For example: printf("%-14s %5ld %s", file->d_name, (long)filestat.st_size, ctime(&filestat.st_mtime)); In this example, the filestate.st_size variable is of the off_t data type. The printf() function lacks a conversion character for off_t, so it has typecast it to a long int. Similar typecasting can be done with other variable types for which printf() lacks a conversion character. But before you go nuts with this trick, check the man page for printf() to ensure that the specific data type lacks a conversion character. A common warning happens when you try to display a long int value by using the %d When that happens, just edit %d to %ld. An “lvalue required” warning indicates that you’ve written a malformed equation. The lvalue is the left value, or the item on the left side of the equation. It must be present and be of the proper type so that the equation is properly handled. The degree to which the compiler flags your code with warnings can be adjusted. Various flags are used to adjust the compiler’s warning level. These flags are set in the Code::Blocks IDE by choosing the Project→Build Options command. The Compiler Flags tab in the Project Build Options dialog box lets you set and reset the various warnings. The “turn on all warnings” option for a command-line C compiler is the -Wall It looks like this: clang -Wall source.c - Wall stands for “warnings, all.” Endless loops in C There’s got to be a way outta here, which is true for just about every loop. The exit condition must exist. In fact, it’s highly recommended that when you set out to code a loop, the first thing you code is the exit condition. As long as it works, you can move forward and write the rest of the joyous things that the loop does. Unintentional endless loops do happen. C programmers run code many times, only to watch a blank screen for a few moments. Oops. Console applications, such as the kind created throughout this book, are halted by pressing the Ctrl+C key combination in a terminal window. This trick may not always work, so you can try closing the window. You can also kill the task, which is a process that’s handled differently by every operating system. For example, in a Unix operating system, you can open another terminal window and use the kill command to rub out a program run amok in the first terminal window. scanf() blunders in C The scanf() function is a handy way to read specific information from standard input. It’s not, however, ideal for all forms of input. For example, scanf() doesn’t understand when a user types something other than the format that’s requested. Specifically, you cannot read in a full string of text. This issue is because scanf() discards any part of the string after the first white space character. Though the fgets() function is a great alternative for capturing text, keep in mind that it can capture the newline that ends a line of text. This character, \n, becomes part of the input string. The other thing to keep in mind when using scanf() is that its second argument is an address, a pointer. For standard variable types — such as int, float, and double — you must prefix the variable name with the &, the address operator: scanf("%d",&some_int); The & prefix isn’t necessary for reading in an array: scanf("%s",first_name); Individual array elements, however, aren’t memory locations, and they still require the & prefix: scanf("%c",&first_name[0]); Pointer variables do not require the & prefix, which could result in unintended consequences. Streaming input restrictions in C The basic input and output functions in the C language aren’t interactive. They work on streams, which are continuous flows of input or output, interrupted only by an end-of-file marker or, occasionally, the newline character. When you plan to read only one character from input, be aware that the Enter key, pressed to process input, is still waiting to be read from the stream. A second input function, such as another getchar(), immediately fetches the Enter key press (the \n character). It does not wait, as an interactive input function would. If you desire interactive programs, get a library with interactive functions, such as the NCurses library. The end-of-file marker is represented by the EOF constant, defined in the h header file. The newline character is represented by the \n escape sequence. The newline character’s ASCII value may differ from machine to machine, so always specify the escape sequence \n for the newline. Want to learn more? Check out our C Programming Cheat Sheet.

View Article
10 Tips and Reminders for C Programmers

Article / Updated 08-04-2022

It’s difficult to narrow down the list of reminders and suggestions, especially for a topic as rich and diverse as programming. For example, an expert could suggest ways to fit in with other programmers, which movies to quote, which games to play, and even which foods to eat. A programming subculture exists — even today, though the emphasis on professional workplace attire has thankfully abated. Beyond social suggestions, there are a few things to remind you of — plus, some general-purpose C programming language recommendations. Believe it or not, every programmer has been through the same things you’ve experienced. It’s good to hear advice from a grizzled programming veteran. Maintain good posture when you’re programming Someone in your early life probably drilled into you the importance of having proper posture. Ignore them at your own peril, especially when you’re young and haven’t yet gotten out of bed to say, “Ouch.” For many programmers, coding becomes an obsession. For most C programmers, it’s quite easy to sit and write code for many hours straight. Such a stationary position is hard on the body. So, every few minutes, take a break. If you can’t manage that, schedule a break. Seriously: The next time you compile, stand up! Look outside! Walk around a bit! While you’re working, try as hard as you can to keep your shoulders back and your wrists elevated. Don’t crook your neck when you look at the monitor. Don’t hunch over the keyboard. Look out a window to change your focus. Remember that it’s pleasant to acknowledge others. True, it’s easy to grunt or snarl at someone when you’re in the midst of a project. Keep in mind that other humans may not appreciate the depth of thought and elation you feel when you code. If you can’t be pleasant now, apologize later. Use creative names in your C programs The best code reads like a human language. It’s tough to make the entire source code read that way, but for small snippets, having appropriate variable and function names is a boon to writing clear code. For example, the following expression is a favorite: while(!done) You can read this statement as “while not done.” It makes sense. Until the value of the donevariable is TRUE, the loop spins. But somewhere inside the loop, when the exit condition is met, the value of done is set equal to TRUE and the loop stops. It’s lucid. It also helps to offer descriptive names to your C functions. A name such as setringervolume() is great, but the name set_ringer_volume() is better. It also helps to consider the function in context. For example: ch=read_next_character(); In the preceding line, the function read_next_character() needs no explanation — unless it doesn’t actually return the next character. Write a function in C Anytime you use code more than once, consider throwing it off into a function, even if the code is only one line long or appears in several spots and doesn’t really seem function-worthy. Suppose that you use the fgets() function to read a string, but then you follow fgets() with another function that removes the final newline character from the input buffer. Why not make both items their own function, something like get_input()? Work on your C code a little bit at a time A majority of the time you spend coding is to fix problems, to correct flaws in logic, or to fine-tune. When making such adjustments, avoid the temptation to make three or four changes at one time. Address issues one at a time. The reason for the admonition is that it’s tempting to hop around your code and work on several things at a time. For example: You need to fix the spacing in a printf() statement’s output, adjust a loop, and set a new maximum value. Do those things one at a time! When you attempt to do several things at a time, you can screw up. But which thing did you goof up? You have to go back and check everything, including the related statements and functions, to ensure they work. During situations like these, you will seriously wish for a time machine. Instead, just work on your code a little bit at a time. Break apart larger C projects into several modules No one likes to scroll through 500 lines of code. Unless you’re totally immersed in your project and can keep everything stored in your noggin, break out functions into modules. Many C programmers prefer to group related functions into similar files. C programmers typically have an output file, an input file, an initialization file, and so on. Each file, or module, is compiled and linked separately to form the code. The benefits are that the files are smaller and if they compile and work, you no longer need to mess with them. Know what a pointer is in C A pointer is a variable that stores a memory location. It’s not magic, and it shouldn’t be confusing, as long as you keep the basic mantra in your head: A pointer is a variable that stores a memory location. A memory location stored in a pointer references another variable or a buffer (like an array). Therefore, the pointer must be initialized before it’s used: A pointer must be initialized before it’s used. When the pointer variable in C is prefixed by the *(asterisk) operator, it references the contents of the variable at the memory location. This duality is weird, of course, but it’s highly useful. Declare a pointer variable by using the * Use the & operator to grab the address of any variable in C. Arrays are automatically referenced by their memory locations, so you can use an array name without the & prefix to grab its address. “Address” and “memory location” are the same thing. A great way to explore pointers is to use the Code::Blocks debugger; specifically, the Watches window. Add white space before condensing your C code C programmers love to bunch up statements, cramming as many of them as they can into a single line, such as while(putchar(*(sample++))) Admit it: Such a construction looks cool. It makes it seem like you really know how to code C. But it can also be a source of woe. My advice: Split out the code before you condense it. Make liberal use of white space, especially when you first write the code. For example, the line if( c != '\0' ) is easier to read than the line if(c!='\0') After you write your code with white space — or use several statements to express something — you can condense, move out the spaces, or do whatever else you like. In C language source code, white space is for the benefit of human eyes. I admire programmers who prefer to use white space over cramming their code onto one line, despite how interesting it looks. Know when if-else becomes switch-case Many C programmers are big fans of the if-else decision tree, but they generally avoid stacking up multiple if statements. It usually means that the programming logic is flawed. For example: if(something) ; else if(something_else) ; else(finally) ; This structure is okay, and it’s often necessary to deal with a 3-part decision. But the following structure, which has been built by many budding C programmers, probably isn’t the best way to code a decision tree: if(something) ; else if(something_else_1) ; else if(something_else_2) ; else if(something_else_3) ; else if(something_else_4) ; else(finally) ; Generally speaking, anytime you have that many else-if statements, you probably need to employ the switch-case structure instead. In fact this example is probably what inspired the switch-case structure in the first place. Remember assignment operators in the C language Though it’s nice to write readable code, one handy tool in the C language is an assignment operator. Even if you don’t use one, you need to be able to recognize it. The following equation is quite common in programming: a = a + n; In C, you can abbreviate this statement by using an assignment operator: a += n; The operator goes before the equal sign. If it went afterward, it might change into a unary operator, which looks weird: a =+ n; So the value of variable a equals positive n? The compiler may buy that argument, but it’s not what you intended. Also, don’t forget the increment and decrement operators, ++ and --, which are quite popular in loops. When you get stuck, read your code out loud To help you track down that bug, start reading your code aloud. Pretend that a programmer friend is sitting right next to you. Explain what your code is doing and how it works. As you talk through your code, you’ll find the problem. If you don’t, have your imaginary friend ask you questions during your explanation. Don’t worry about going mental. You’re a C programmer. You’re already mental. As a bonus, talking through your code also helps you identify which portions need to have comments and what the comments should be. For example: a++; /* increment a */ In the preceding line, you see a terrible example of a comment. Duh. Of course, a is incremented. Here’s a better version of that comment: a++; /* skip the next item to align output */ Don’t just comment on what the code is doing — comment on why. Again, pretend that you’re explaining your code to another programmer — or to future-you. Future-you will thank present-you for the effort. Want to learn more? Check out our C Programming For Dummies Cheat Sheet.

View Article
Word 2013 For Dummies Cheat Sheet

Cheat Sheet / Updated 08-01-2022

If you are using Microsoft Word 2013, this Cheat Sheet will help you use it more efficiently with a list of handy keyboard shortcuts, special-character shortcuts, and some tips and tricks.

View Cheat Sheet
PCs For Dummies Cheat Sheet

Cheat Sheet / Updated 04-12-2022

Even though computers are supposed to make our lives easier, you may find it beneficial to print and complete some information about your personal computer (PC) on paper. You can use this as a reference for technical information, internet, and email information, or how all those wires and peripherals should be hooked up to your PC — even while the computer is off. You’ll also want to check out the following list of helpful PC hints.

View Cheat Sheet
Running for Local Office For Dummies Cheat Sheet

Cheat Sheet / Updated 04-05-2022

You want to ensure that your run for office is successful. This Cheat Sheet provides some tips on campaigning, including preparing for a local political campaign by working on your name recognition, public reputation, and campaign finances. You also need to make sure that you have some important assets in place, like a campaign manager, volunteers, and voter lists.

View Cheat Sheet
Word 2016 For Dummies Cheat Sheet

Cheat Sheet / Updated 03-25-2022

Word is one of the most used computer programs on the planet. Helping you to compose text is one of the things that computers do well, but that doesn’t make the text-writing chore easier or imply that using Word is simple enough that you don’t need help. So enjoy this Cheat Sheet.

View Cheat Sheet
Parenting For Dummies Cheat Sheet

Cheat Sheet / Updated 03-09-2022

Following some helpful advice about parenting will help you keep your cool and forge ahead with enthusiasm even when the going gets rough. In case of a family emergency, make sure you have a list handy of emergency phone numbers and that everyone in the house knows where it is. Parenting comes with a set of absolute rules, so get to know and consistently practice them. When you can't figure out why your baby is crying, go through a list of possible reasons and their remedies from top to bottom.

View Cheat Sheet
Laptops For Dummies Cheat Sheet

Cheat Sheet / Updated 02-24-2022

Nothing is more liberating than having a computer you can take with you. A laptop offers you full computer power, a decently sized keyboard, a nice-looking display, and the ability to go wireless — not to mention how cool you look checking email and Facebook at Starbucks.

View Cheat Sheet
Troubleshooting & Maintaining Your PC All-in-One For Dummies Cheat Sheet

Cheat Sheet / Updated 02-18-2022

Dive into this guide for your PC troubleshooting and maintenance needs. Refer here for tips, tricks, and information when your computer starts acting funny. Sadly, funny computer smells aren’t covered.

View Cheat Sheet
page 1
page 2
page 3
page 4
page 5
page 6
page 7
page 8
page 9
page 10
page 11
page 12
page 13
page 14
page 15
page 16
page 17
page 18
page 19
page 20
page 21
page 22
page 23
page 24
page 25
page 26
page 27
page 28
page 29
page 30
page 31
page 32
page 33
page 34
page 35
page 36
page 37
page 38
page 39
page 40
page 41
page 42
page 43
page 44
page 45
page 46
page 47
page 48
page 49
page 50
page 51
page 52
page 53
page 54
page 55
page 56
page 57
page 58
page 59
page 60
page 61
page 62
page 63
page 64
page 65
page 66
page 67
page 68
page 69
page 70
page 71
page 72
page 73