Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the name of the header file that contains the declaration of malloc?

Tags:

c++

c

malloc

What is the name of the header file that contains the declaration of the malloc() function in C and C++?

like image 531
Peter Avatar asked Sep 03 '11 09:09

Peter


People also ask

What is the header file for malloc?

The malloc() function in C++ allocates a block of uninitialized memory to a pointer. It is defined in the cstdlib header file.

What is #include malloc h in C?

h is a standard C header that declares among other things the malloc() , calloc() , free() functions. This is the header you should include. malloc. h is a non-standard header, found on many systems where it often defines additional functions specific to the malloc implementation used by that platform.

What is declaration in header file?

2) Declaring a static variable in a header means that each source file that includes it will have its own version of that variable rather than a single shared variable.

How do you declare malloc?

Syntax: ptr = (cast-type*) malloc(byte-size) For Example: ptr = (int*) malloc(100 * sizeof(int)); Since the size of int is 4 bytes, this statement will allocate 400 bytes of memory.


1 Answers

It's in stdlib.h (C) and cstdlib (C++).

In general, for such questions, just try to look on google: "c++ function". Most often the first hit will point to cplusplus.com for me containing a complete reference to the standard stuff.

like image 133
Mario Avatar answered Oct 04 '22 13:10

Mario