Professional Documents
Culture Documents
[C Frequently
Debugging is easier
It is easier to understand the logic involved in the program
Testing is easier
Recursive call is possible
Irrelevant details in the user point of view are hidden in functions
Functions are helpful in generalizing the program
Can the sizeof operator be used to tell the size of an array passed to a
function?
No. Theres no way to tell, at runtime, how many elements are in an array
parameter just by looking at the array parameter itself. Remember, passing an array
to a function is exactly the same as passing a pointer to the first element.
specify a size thats known only at runtime. For example, if i is a variable, you cant
write code like this:
char array[i]; /* not valid C */
Some languages provide this latitude. C doesnt. If it did, the stack would be more
complicated, function calls would be more expensive, and programs would run a lot
slower. If you know that you have an array but you wont know until runtime how
big it will be, declare a pointer to it and use malloc() or calloc() to allocate the array
from the heap.
the stdout standard stream within your program to a file named OUTPUT.TXT, you
would implement the freopen() function as shown here:
... freopen(output.txt, w, stdout);
...
Now, every output statement (printf(), puts(), putch(), and so on) in your program
will appear in the file OUTPUT.TXT.
What is a method?
Method is a way of doing something, especially a systematic way; implies an orderly
logical arrangement (usually in steps).
What is indirection?
If you declare a variable, its name is a direct reference to its value. If you have a
pointer to a variable, or any other object in memory, you have an indirect reference
to its value.
{
#if DEMO_VERSION
printf(Sorry! You cant save documents using the DEMO version of this
programming);
return(0);
#endif
...