answersLogoWhite

0


Best Answer

void

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the datatype of the pointer returned by malloc function?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the default datatype of the pointer returned by malloc function?

void


How to use free with respect to malloc?

If malloc() returns a pointer to space for an object of size size1(or NULL if the request cannot be satisfied) when invoked that returned pointer can be assigned to a pointer varialbe P of respective type *P; P=malloc(size1); if the above function call is successful P points to space of size size1 That memory space can be freed as free(p); free deallocates the space pointed to by p; it does nothing if p is NULL


Malloc uses which datatype?

size_t for input, void * for output


What is falloc?

falloc is a function similar to malloc. Where the function malloc returns a pointer to an area of memory, falloc returns a "far" pointer to a "far" area of memory; i.e., memory that goes beyond the segmented memory limitations inherent to x86 memory architecture.


What is the malloc function?

The malloc function is one of a group of memory allocation functions; malloc, calloc, realloc, and free. Specifically malloc (size) returns a pointer to a new memory block of at least size bytes, suitably aligned for optimum access for any basic type, or it returns a NULL if the request cannot be satisfied.


What is a malloc function in C programming with example?

The malloc() function is part of a class of functions that deal with the allocation of memory on the heap. int *a = malloc (sizeof (int) * 100); /* allocate 100 int's */ if (a == NULL) {...} /* deal with possible malloc failure */ /* use a, either as pointer or as array of 100 ints */ free (a); /* release memory back to the library */


What is really meant by malloc and where you will use this malloc?

malloc is a function of the standard c library (stdlib) and it is abbreviation for memory allocate. What this function does is allocates memory in the RAM of computer to store variable data in it. You will use it whenever you need a place to store you temporary data such as an array or structure. To use malloc all you have to do is call malloc and tell it the size of the memory you want. It will then return a pointer to that memory. persumabely if it fails it returns NULL.


71 Which function should be used to free the memory allocated by calloc?

free() is a function used to free the memory allocated dynamically ,by both malloc and calloc functions. free(ptr): ptr is a pointer to a memory block which has already been creeated by malloc or calloc.


How is memory management achieved by pointers in c plus plus?

Memory management in C++ is achieved using the new and delete operators. These operators are synonymous with the malloc() and free() functions found in C, and which you can also use in C++ but then your code would not strictly be C++. However, the new and delete operators are implemented behind the scenes with malloc() and free(), so the distinction at this level is somewhat moot.Although the new operator and malloc() function effectively do the same job, the new operator greatly simplifies the process. Whereas malloc() requires that you specify the exact amount of memory required, the newoperator can determine the amount at compile time, based upon the type of memory required. Moreover, the new operator returns a pointer to the required type whereas the pointer returned by malloc() must be cast to the appropriate type.There's very little difference between the deleteoperator and the free() function, however they are not interchangeable. If memory was allocated with the newoperator, then it must be released with the delete operator, not the free() function.Apart from these differences, memory management in C++ is much the same as it was with C. Whether memory is allocated with the new operator or the malloc() function, you must maintain a pointer variable to hold the reference that is returned (or a NULL value if the allocation failed). When the memory is no longer required, it must be released back to the system by deleting or freeing the original pointer or a copy of the original pointer. At that point, all pointers to that memory are deemed invalid, and should be zeroed to ensure they no longer refer to invalid memory.Note that the malloc() function also has two variants: calloc() and realloc(). calloc() works much the same as malloc() but is used to allocate a count of contiguous memory blocks, like an array, while realloc() is used to release an existing allocation and allocate another to the same pointer. There is no equivalent operator for realloc()in C++.


Difference between malloc and alloc?

alloc is used as header file while using malloc and calloc functions in C prog.The definition of malloc function is in the alloc.h file.It's stdlib.h to be more precise


Could malloc assign memory for object?

Malloc is a memory allocation. You specify the amount of memory you need and are given a pointer to that much memory. It doesn't "assign" anything to that value, it just gives you a pointer. At that point you should put whatever you want in there.


How you use malloc function in c?

void* malloc (size_t bytes); This means that malloc takes an argument which is the size of memory to allocate and returns a pointer to that memory which has been allocated. If the return value is NULL, then the request could not be satisfied. Each call to malloc must be balanced with a corresponding call to free, to release the memory. int pa = NULL; pa = (int*) malloc (sizeof(int) * 1000); /* allocate 1000 ints */ if (pa == NULL) throw exception... ... use pa free (pa); pa = NULL;