disadvantages of macros
Part I -Macros
1. Macros make program readable
eg: #define sqr(a) a*a
so everytime preprocessor will replace say sqr(2) by 2*2
so they r easier to use instead of functions in some cases
2. Macros are faster than functions
Macros may make compiling slower but compiled programs are faster
because functions involve passing values which increase cpu usage.
3. They make our prog compact
4. Defining arbitrary constants is easy.
eg:-
#define matrix_size 3
main()
{
int mat[matrix_size][matrix_size];
/*ur rest program on processing matrix*/
}
Thus in above case the arbitrary constant matrix_size can be changed
instead of changing each and every process step.
5. Macros can used to shorten frequently used commands or operations.
Part II - malloc() and calloc()
malloc() - Allocates a specified number of bytes in memory. Returns a pointer
to the beginning of the allocated block
calloc() - Similar to malloc(), but initialises the allocated bytes to zero. This
function also allows us to allocate memory for more than one object
at a time.