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

Parsam sai bharath said:   1 decade ago
Actually return type of malloc() or calloc() void pointer. So should typecast it.

Mohan said:   1 decade ago
Actually we use pointer for p, then why we need another pointer for the location.

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

Priyanka Bedre said:   1 decade ago
Can we write this program like.

char p;
p= (char *) malloc (1000) ;

Shailesh said:   1 decade ago
Please explain why we use a pointer.

With real time example.

Plz?

Sanjay Tiwari said:   1 decade ago
Since we know that decleration+initialization=can we write.

Mahes said:   1 decade ago
I want clear details in pointer?why we use this concept?

Rishikesh said:   5 years ago
Prototype of malloc = ptr = (data type *)malloc(size);
(8)

Umashankar Singh said:   1 decade ago
Please can an one explain malloc and calloc function ?

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


Post your comments here:

Your comments will be displayed after verification.