Mat.S
Mat.S

Reputation: 1854

What is the datatype of &(char *) in C?

Suppose I have

char *t = "XX";

I am wondering what is the type of &t. Is it char or array?

Upvotes: 0

Views: 102

Answers (3)

JaredPar
JaredPar

Reputation: 755289

The type of &t for any expression is a pointer to the type of t. In this case the type of t is char* hence the the type of &t is char**

Upvotes: 4

Lucio
Lucio

Reputation: 5428

You need to know what a pointer is and who does it works.

TYPE * VAR = VALUE;

Here you have:

  • TYPE: the type of data that you are storing
  • *: means it is a pointer of TYPE
  • VAR: is the variable that store a pointer of TYPE
  • VALUE: value of TYPE

And &VAR is a pointer to VAR. In your case VAR is a pointer also, so &VAR is a pointer to a pointer.

Upvotes: 1

unxnut
unxnut

Reputation: 8839

Since t is a pointer, &t is a pointer to a pointer.

Upvotes: 4

Related Questions