Sorry if this question sounds a bit retarded, still new to C programming.
Why is malloc necessary if the same result can be obtained by simply using sizeof, declared in the header file limits.h, rather than malloc in stdlib.h?
Sorry if this question sounds a bit retarded, still new to C programming.
Why is malloc necessary if the same result can be obtained by simply using sizeof, declared in the header file limits.h, rather than malloc in stdlib.h?
malloc and sizeof do very different things. sizeof is an operator; it is not declared in any header file. Perhaps you could show code to demonstrate your thoughts?Originally Posted by ItzBlue
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Oh, figured. Thanks for clearing it up.
sizeof would tell you the size of a thing in bytes. malloc() takes a specific number of bytes and allocates them on the heap.