Question discussion

How do you combine the following two statements?char *p;p = (char*) malloc (100);

175229Medium 1 reply 2,446 views
28
How do you combine the following two statements?
char *p;
p = (char*) malloc (100);
  • Achar p = *malloc(100);
  • Bchar *p = (char)malloc(100);
  • Cchar *p = (char*)malloc(100);
  • Dchar *p = (char*)(malloc*)(100);
Answer not set

Discussion 1

0
CCommunity
A pointer is a group of cells (often two or four) that can hold an address. The unary operator &. gives the address of an object.

The unary operator * is the indirection or dereferencing operator; when applied to a pointer, it accesses the object the pointer points to.

Char pointers are defined as follows:

char *ptr = (char*)malloc(size)