What do Segmentation violation, `Bus error, and General protection fault mean? What is a core dump?
What do Segmentation violation, `Bus error, and General protection fault mean? What is a core dump? These symptoms (and any similar messages having to do with memory access violations or protection faults) generally mean that your program tried to access memory it shouldn't have, invariably as a res... 2015-05-20, 639👍, 0💬
What is the best style for code layout in C?
What is the best style for code layout in C? While providing the example most often copied, also supply a good excuse for disregarding it: The position of braces is less important, although people hold passionate beliefs. We have chosen one of several popular styles. Pick a style that suits you, the... 2015-05-18, 638👍, 0💬
How should functions be apportioned among source files?
How should functions be apportioned among source files? Usually, related functions are put together in one file. Sometimes (as when developing libraries) it is appropriate to have exactly one source file (and, consequently, one object module) per independent function. Other times, and especially for... 2015-05-18, 622👍, 0💬
Here is a neat trick for checking whether two strings are equal
Q: Here's a neat trick for checking whether two strings are equal: if(!strcmp(s1, s2)) Is this good style? It is not particularly good style, although it is a popular idiom. The test succeeds if the two strings are equal, but the use of ! (``not'') suggests that it tests for inequality. Another opti... 2015-05-15, 671👍, 0💬
Why do some people write if(0 == x) instead of if(x == 0)?
Why do some people write if(0 == x) instead of if(x == 0)? It's a trick to guard against the common error of writing if(x = 0) If you're in the habit of writing the constant before the ==, the compiler will complain if you accidentally type if(0 = x) Evidently it can be easier for some people to rem... 2015-05-15, 628👍, 0💬
I came across some code that puts a (void) cast before each call to printf. Why?
I came across some code that puts a (void) cast before each call to printf. Why? printf does return a value (the number of characters printed, or an error code), though few programs bother to check the return values from each call. Since some compilers (and lint) will warn about discarded return val... 2015-05-13, 635👍, 0💬
If NULL and 0 are equivalent as null pointer constants, which should I use?
If NULL and 0 are equivalent as null pointer constants, which should I use? Many programmers believe that NULL should be used in all pointer contexts, as a reminder that the value is to be thought of as a pointer. Others feel that the confusion surrounding NULL and 0 is only compounded by hiding 0 b... 2015-05-11, 678👍, 0💬
Should I use symbolic names like TRUE and FALSE for Boolean constants, or plain 1 and 0?
Should I use symbolic names like TRUE and FALSE for Boolean constants, or plain 1 and 0? It's your choice. Preprocessor macros like TRUE and FALSE (and, of course, NULL) are used for code readability, not because the underlying values might ever change. It's a matter of style, not correctness, wheth... 2015-05-11, 632👍, 0💬
What is Hungarian Notation? Is it worthwhile?
What is Hungarian Notation? Is it worthwhile? Hungarian Notation is a naming convention, invented by Charles Simonyi, which encodes information about a variable's type (and perhaps its intended use) in its name. It is well-loved in some circles and roundly castigated in others. Its chief advantage i... 2015-05-08, 640👍, 0💬
Some people say that gotos are evil and that I should never use them. Isnt that a bit extreme
Some people say that gotos are evil and that I should never use them. Isnt that a bit extreme rogramming style, like writing style, is somewhat of an art and cannot be codified by inflexible rules, although discussions about style often seem to center exclusively around such rules. In the case of th... 2015-05-08, 644👍, 0💬
People always say that good style is important
People always say that good style is important, but when they go out of their way to use clear techniques and make their programs readable, they seem to end up with less efficient programs. Since efficiency is so important, isn't it necessary to sacrifice some style and readability? It's true that g... 2015-05-06, 659👍, 0💬
I just typed in this program, and it is acting strangely. Can you see anything wrong with it?
I just typed in this program, and it is acting strangely. Can you see anything wrong with it? See if you can run lint first (perhaps with the -a, -c, -h, -p or other options ). Many C compilers are really only half-compilers, taking the attitude that it's not their problem if you didn't say what you... 2015-05-06, 641👍, 0💬
How can I shut off the warning ...
How can I shut off the ``warning: possible pointer alignment problem'' message which lint gives me for each call to malloc? A modern lint shouldn't be complaining about this. Once upon a time, lint did not and could not know that malloc ``returns a pointer to space suitably aligned for storage of an... 2015-05-05, 631👍, 0💬
Where can I get an ANSI-compatible lint?
Where can I get an ANSI-compatible lint? Products called PC-Lint and FlexeLint are available from Gimpel Software. The Unix System V release 4 lint is ANSI-compatible, and is available separately (bundled with other C tools) from UNIX Support Labs or from System V resellers. Another ANSI-compatible ... 2015-05-05, 680👍, 0💬
Dont ANSI function prototypes render lint obsolete?
Dont ANSI function prototypes render lint obsolete? Not really. First of all, prototypes work only if they are present and correct; an inadvertently incorrect prototype is worse than useless. Secondly, lint checks consistency across multiple source files, and checks data declarations as well as func... 2015-05-01, 642👍, 0💬
I need code to parse and evaluate expressions.
I need code to parse and evaluate expressions. Two available packages are ``defunc,'' posted to comp.sources.misc in December, 1993 (V41 i32,33), to alt.sources in January, 1994, and available from sunsite.unc.edu in pub/packages/development/libra ries/defunc-1.3.tar.Z,and ``parse,'' at lamont.ldgo.... 2015-05-01, 634👍, 0💬
How can I read a single character from the keyboard without waiting for the RETURN key?
How can I read a single character from the keyboard without waiting for the RETURN key? How can I stop characters from being echoed on the screen as they're typed? Alas, there is no standard or portable way to do these things in C. Concepts such as screens and keyboards are not even mentioned in the... 2015-04-29, 922👍, 0💬
How can I find out if there are characters available for reading?
How can I find out if there are characters available for reading (and if so, how many)? Alternatively, how can I do a read that will not block if there are no characters available? These, too, are entirely operating-system-specific. Some versions of curses have a nodelay function. Depending on your ... 2015-04-29, 649👍, 0💬
How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indica
How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators? These simple things, at least, you can do fairly portably. Printing the character '\r' will usually give you a carriage return without a line feed, so that you can ov... 2015-04-27, 774👍, 0💬
How can I clear the screen? How can I print text in color? How can I move the cursor to a specific x, y position?
How can I clear the screen? How can I print text in color? How can I move the cursor to a specific x, y position? Such things depend on the terminal type (or display) you're using. You will have to use a library such as termcap, terminfo, or curses, or some system-specific routines, to perform these... 2015-04-27, 714👍, 0💬
How can I make it pause before closing the program output window?
I'm compiling some test programs on a windows-based system, and the windows containing my program's output are closing so quickly after my program calls exit that I can't see the output. How can I make it pause before closing? After wondering why the author of your compiler's run-time system didn't ... 2015-04-24, 657👍, 0💬
How do I read the arrow keys? What about function keys?
How do I read the arrow keys? What about function keys? Terminfo, some versions of termcap, and some versions of curses have support for these non-ASCII keys. Typically, a special key sends a multicharacter sequence (usually beginning with ESC, '\033'); parsing these can be tricky. (curses will do t... 2015-04-24, 659👍, 0💬
How can I do serial comm port I O?
How can I do serial (``comm'') port I/O? It's system-dependent. Under Unix, you typically open, read, and write a device file in /dev, and use the facilities of the terminal driver to adjust its characteristics.Under MS-DOS, you can use the predefined stream stdaux, or a special file like COM1, or s... 2015-04-22, 708👍, 0💬
How can I direct output to the printer?
How can I direct output to the printer? Under Unix, either use popen to write to the lp or lpr program, or perhaps open a special file like /dev/lp. Under MS-DOS, write to the (nonstandard) predefined stdio stream stdprn, or open the special files PRN or LPT1. Under some circumstances, another (and ... 2015-04-22, 710👍, 0💬
How To Create an Add-to-Bloglines Button on Your Website? - RSS FAQs - Adding Your Feeds to RSS News...
How can we suppress a finalize method? GC.SuppressFinalize ()
What are the standard ways of parsing XML document? XML parser sits in between the XML document and ...
How can I enable session tracking for JSP pages if the browser has disabled cookies? We know that se...
Do You Know the Book "JUnit in Action"? You should know this book. It received some good reviews. Ti...