C Programming - Pointers - Discussion

Discussion Forum : Pointers - General Questions (Q.No. 2)
2.
Can you combine the following two statements into one?
char *p;
p = (char*) malloc(100);
char p = *malloc(100);
char *p = (char) malloc(100);
char *p = (char*)malloc(100);
char *p = (char *)(malloc*)(100);
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
82 comments Page 7 of 9.

Prasath said:   1 decade ago
1) All memories allocated by memory management API's like malloc and calloc will be allocated from the Heap partition of the program.

2) Both malloc and calloc will allocate memories but, malloc just allocate required memory leaving the garbage value as it is but calloc allocate memory required and clear it with 0.

Abhijit kamune said:   1 decade ago
Hey tell me where actually memory get allocate when we use malloc(), or calloc().

What is main diff between malloc() and calloc() ?

Rajesh said:   1 decade ago
Thanks kavyashri and mahesh for good explanation.

Vinoth said:   1 decade ago
Good example given by arunpandian

Minu kutty said:   1 decade ago
I need complete details about pointers and c++ is better than c or not.

Jeevanantham said:   1 decade ago
The malloc() function is a memory allocation type. It allocats memory in bytes and also return the pointer to allocated memory.

Jadhi said:   1 decade ago
I want to know about malloc clearly.

Manish said:   1 decade ago
I didnt understand about pointer,how it is work in c.

What is the difference between pointer of c and c++.?

Saran said:   1 decade ago
Here we have to allocate space for char.

Suma sahithi said:   1 decade ago
Thanks Mahesh and Kavyasri for the explanation.


Post your comments here:

Your comments will be displayed after verification.