| 0 Comments |
The function realloc(ptr,n) uses two arguments.the first argument ptr is a pointer to a block of memory for which the size is to be altered.The second argument n specifies the
new size.The size may be increased or decreased.If n is greater than the old size and if sufficient space is not available subsequent [...]
| 0 Comments |
The hardest part about using a pointer-to-function is declaring it.
Consider an example. You want to create a pointer, pf, that points to the strcmp() function.
The strcmp() function is declared in this way:
int strcmp(const char *, const char * )
To set up pf to point to the strcmp() function, you want a declaration that [...]
| 1 Comment |
The heap is where malloc(), calloc(), and realloc() get memory.
Getting memory from the heap is much slower than getting it from the stack. On the other hand, the heap is much more flexible than the stack. Memory can be allocated at any time and deallocated in any order. Such memory isn’t deallocated [...]
| 0 Comments |
The preceding example showed how you can redirect a standard stream from within your program. But what if later in your program you wanted to restore the standard stream to its original state? By using the standard C library functions named dup() and fdopen(), you can restore a standard stream such as [...]
| 0 Comments |
The preprocessor is used to modify your program according to the preprocessor directives in your source code. Preprocessor directives (such as #define) give the preprocessor specific instructions on how to modify your source code. The preprocessor reads in all of your include files and the source code you are compiling and [...]
| 0 Comments |
The preprocessor will include whatever file you specify in your #include statement. Therefore, if you have the line #include
in your program, the file macros.inc will be included in your precompiled program. It is, however, unusual programming practice to put any file that does not have a .h or .hpp extension in [...]
| 0 Comments |
The safest way is to use printf () (or fprintf () or sprintf ()) with the %P specification. That prints a void pointer (void*). Different compilers might print a pointer with different formats. Your compiler will pick a format that’s right for your environment.
If you have some other kind of pointer (not [...]
| 0 Comments |
The stack is where all the functions’ local (auto) variables are created. The stack also contains some information used to call and return from functions.
A “stack trace” is a list of which functions have been called, based on this information. When you start using a debugger, one of the first things you should [...]