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);
Discussion:
82 comments Page 5 of 9.
Rafael Bluhm said:
1 decade ago
Is not correct to cast*void types in C. Malloc returns a void pointer, and compiles cast it automatically.
The correct is char*p = malloc(100);
The correct is char*p = malloc(100);
Rashmi said:
1 decade ago
Here malloc (100) give the address and then by char*malloc (100) we got the value that is placed on that address.
And now we assign that value to char p* by that we get a pointer of char type.
And now we assign that value to char p* by that we get a pointer of char type.
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() ?
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++.?
What is the difference between pointer of c and c++.?
Saran said:
1 decade ago
Here we have to allocate space for char.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers