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 9 of 9.

Mahesh said:   2 decades ago
Here we have to allocate space for characters.so first we have to do typecasting i.e (char *).

If we give (char) it gives error because we are using pointer, then we allocate memory space by malloc().

Lingarajathi said:   2 decades ago
Hello Mr/Ms

I need clear details about pointers and pointers memory allocation, can you send me this me the details.


Post your comments here:

Your comments will be displayed after verification.