<< < 10 11 12 13 14 15 16 17 > >>   Sort: Rank

Modulation Operations
Write an equivalent expression for x%8? x&amp;7
2007-02-26, 6895👍, 0💬

Nesting Include Files
Can include files be nested? The answer is yes. Include files can be nested any number of times. As long as you use precautionary measures , you can avoid including the same file twice. In the past, nesting header files was seen as bad programming practice, because it complicates the dependency trac...
2007-02-26, 6699👍, 0💬

"const" and "volatile"
Can a variable be both const and volatile? Yes. The const modifier means that this code cannot change the value of the variable, but that does not mean that the value cannot be changed by means outside this code. For instance, a timer structure can be accessed through a volatile const pointer. The f...
2007-02-26, 7056👍, 0💬

Determining If Symbols Are Defined or Not
How can you check to see whether a symbol is defined? You can use the #ifdef and #ifndef preprocessor directives to check whether a symbol has been defined (#ifdef) or whether it has not been defined (#ifndef). Can you define which header file to include at compile time? Yes. This can be done by usi...
2007-02-26, 6413👍, 0💬

Overriding Defined Macros
How do you override a defined macro? You can use the #undef preprocessor directive to undefine (override) a previously defined macro.
2007-02-26, 6598👍, 0💬

Can Static Variables Be Declared in Header Files
Can static variables be declared in a header file? You can't declare a static variable without defining it as well (this is because the storage class modifiers static and extern are mutually exclusive). A static variable can be defined in a header file, but this would cause each source file that inc...
2007-02-26, 8323👍, 0💬

Determing the Size of Allocated Memory Blocks
How can you determine the size of an allocated portion of memory? You can't, really. free() can , but there's no way for your program to know the trick free() uses. Even if you disassemble the library and discover the trick, there’s no guarantee the trick won’t change with the next release of the co...
2007-02-26, 6480👍, 0💬

What is page thrashing
What is page thrashing? Some operating systems (such as UNIX or Windows in enhanced mode) use virtual memory. Virtual memory is a technique for making a machine behave as if it had more memory than it really has, by using disk space to simulate RAM (random-access memory). In the 80386 and higher Int...
2007-02-26, 6666👍, 0💬

"register" Modifier
When should the register modifier be used? Does it really help? The register modifier hints to the compiler that the variable will be heavily used and should be kept in the CPU's registers, if possible, so that it can be accessed faster. There are several restrictions on the use of the register modi...
2007-02-26, 9312👍, 0💬

"volatile" Modifier
when should the volatile modifier be used? The volatile modifier is a directive to the compiler's optimizer that operations involving this variable should not be optimized in certain ways. There are two special cases in which use of the volatile modifier is desirable. The first case involves memory-...
2007-02-26, 6713👍, 0💬

What Is the Quickest Sorting Method?
What is the quickest sorting method to use? The answer depends on what you mean by quickest. For most sorting problems, it just doesn't matter how quick the sort is because it is done infrequently or other operations take significantly more time anyway. Even in cases in which sorting speed is of the...
2007-02-26, 6648👍, 0💬

What Is Hashing
What is hashing? To hash means to grind up, and that's essentially what hashing is all about. The heart of a hashing algorithm is a hash function that takes your nice, neat data and grinds it into some random-looking integer. The idea behind hashing is that some data either has no inherent ordering ...
2007-02-26, 6781👍, 0💬

Opening Files to Share with Other Programs
How can I open a file so that other programs can update it at the same time? Your C compiler library contains a low-level file function called sopen() that can be used to open a file in shared mode. Beginning with DOS 3.0, files could be opened in shared mode by loading a special program named SHARE...
2007-02-26, 6291👍, 0💬

enum vs. define Statements
What is the benefit of using an enum rather than a #define constant? The use of an enumeration constant (enum) has many advantages over using the traditional symbolic constant style of #define. These advantages include a lower maintenance requirement, improved program readability, and better debuggi...
2007-02-26, 10622👍, 0💬

Including Source Files
What is the result of using Option Explicit? When writing your C program, you can include files in two ways. The first way is to surround the file you want to include with the angled brackets &lt; and &gt;. This method of inclusion tells the preprocessor to look for the file in the predefine...
2007-02-26, 6909👍, 0💬

Swapping Variables
Can you write a program to interchange 2 variables without using the third one? a = 7; b = 2; a = a + b; b = a - b; a = a - b;
2007-02-26, 6301👍, 0💬

Calling Base Class Methods
How can method defined in multiple base classes with same name be invoked from derived class simultaneously? class x { public: m1(); }; class y { public: m1(); }; class z: public x, public y { public: m1() { x::m1(); y::m1(); } };
2007-02-26, 6428👍, 0💬

Pointer to Constants
What is the difference between const char* p and char const* p? In const char* p, the character pointed by "p" is constant, so you can not change the value of character pointed by p but u can make "p" refer to some other location. In char const* p, the pointer "p" is constant not the character refer...
2007-02-26, 6594👍, 0💬

malloc Function
Why does malloc(0) return valid memory address? What's the use? malloc(0) does not return a non-NULL under every implementation. An implementation is free to behave in a manner it finds suitable, if the allocation size requested is zero. The implmentation may choose any of the following actions: * A...
2007-02-26, 6914👍, 0💬

Convert an integer or a float to a string
Does there exist any other function which can be used to convert an integer or a float to a string? Some implementations provide a nonstandard function called itoa(), which converts an integer to string. char *itoa(int value, char *string, int radix); DESCRIPTION - The itoa() function constructs a s...
2007-02-26, 8442👍, 0💬

Bitwise Operations
Which bit wise operator is suitable for turning on a particular bit in a number? The bitwise OR operator. In the following code snippet, the bit number 24 is turned ON: enum { KBit1 = 0x00000001 KBit2 = 0x00000010, KBit3 = 0x00000100, ... }; some_int = some_int | KBit24;
2007-02-26, 7434👍, 0💬

Bitwise Operations
Which bit wise operator is suitable for turning off a particular bit in a number? The bitwise AND operator. Here is an example: enum { KBit1 = 0x00000001 KBit2 = 0x00000010, KBit3 = 0x00000100, ... }; some_int = some_int &amp; ~KBit24;
2007-02-26, 9709👍, 0💬

Bitwise Operations
Which bit wise operator is suitable for checking whether a particular bit is on or off? The bitwise AND operator. Here is an example: enum { KBit1 = 0x00000001 KBit2 = 0x00000010, KBit3 = 0x00000100, ... }; if ( some_int & KBit24 ) printf("Bit number 24 is ON\n"); else printf("Bit number 24 is O...
2007-02-26, 8011👍, 0💬

Multi-dimension Arrays
Write down the equivalent pointer expression for referring the same element a[i][j][k][l]? a[i] == *(a+i) a[i][j] == *(*(a+i)+j) a[i][j][k] == *(*(*(a+i)+j)+k) a[i][j][k][l] == *(*(*(*(a+i)+j)+k)+l)
2007-02-26, 6498👍, 0💬

<< < 10 11 12 13 14 15 16 17 > >>   Sort: Rank