C Programming - Memory Allocation - Discussion
Discussion Forum : Memory Allocation - True / False Questions (Q.No. 1)
1.
malloc() returns a float pointer if memory is allocated for storing float's and a double pointer if memory is allocated for storing double's.
Discussion:
16 comments Page 2 of 2.
Balaji said:
1 decade ago
Can't get your point @Ashwin is that malloc doesn't return float?
DEBENDRA KUMAR SAHOO said:
1 decade ago
Return type depend on typecast like p = (int*)malloc(90).
It will return integer type pointer.
It will return integer type pointer.
Prabin said:
10 years ago
Malloc and calloc always returns void pointers.
Anushka said:
9 years ago
But I think as address can never be float or double so there is no matter to return of float or double pointer.
Amol said:
8 years ago
Thanks @Anil and @Ashwin.
Bala Aathikesavan said:
2 years ago
I think malloc() always returns the void pointer.
Syntax:
void * malloc(size_t)
int *ptr=(int *)malloc(4)
Here malloc returns the void pointer and we typecasted as an integer here using(int) and it will be stored in a ptr.
Syntax:
void * malloc(size_t)
int *ptr=(int *)malloc(4)
Here malloc returns the void pointer and we typecasted as an integer here using(int) and it will be stored in a ptr.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers