What is the data type of pointer variables?

I referenced the following link:

Link1 Link 2

In the above link1, the answer said that " Pointers are of pointer type".

I just need to know if the pointer is a data type or not.

No one answered this question in one word. Is it a data type or not?

This is the second link to which I refer, says that

Pointers are just a variable that contains an address, so it can be argued that a pointer is a data type, but it is not defined as a data type (in “C programming language.” Kernigan and Richie).

+7
source share
7 answers

, - . ( C) void *. A void * ( ), . - , , , , , , , . , , void - "". A void * , , , void * (, int *) .

, , (), char , int , double . , . , , . void *.

, void * : , ( ). , C , : char *, int *, double * ..
: (char *) void * my_ptr;

:

, :

char a_character = 'a';  //type: a char
char *a_char_ptr = &a_character; //memory address, in this case, the one holding a_charachter

, , , :

printf("%zu <> %zu\n", sizeof a_character, sizeof a_char_ptr);

- "1 < > 8" "1 < > 4", , . .

printf: %p:

printf("%c is the value stored at %p\n", *a_char_ptr, (void *) a_char_ptr);

( ), , void *. void - ; , , . , malloc, calloc realloc return, , . , char *? , 1 (sizeof(char)). , , : char * (char *) void *my_ptr;

, ? , - , , . char . int . : char *x char, char * ( char). , char *x , char.

, TL; TR:

, - (void * ). ( ). , , , C (, char *, int * ..). , , .

+15

.

: " ?". : . , :

int *ptr;

ptr - -, int*, .

: " - ". " " .

C " ", () . , " " , .

, , . : , , , , .. . ( , 2011 .)

"" . "" , (, , malloc ). "" , , :

  • ;
  • - ( );
  • (, );
  • ( , ).

- . - - ; " , ". , - .

Link 2, - , " - , , , - , (" C ". )". , K & R " "; , , . , K & R, .

: , ?

+6

, C . . , .

, , , .

- C

3.15
1 object
region of data storage in the execution environment, the contents of which can represent
values

, . , - , , . , - . , .

, , , .

, - !:)

+3

, - , .

+2

- . , , .

+1

- ; .

; int char, double, 10- int, 11- int ..

; , , void * char *.

+1

, , " ", , .

, , uintptr_t void *.

: "uintptr_t - , . , , "

, : 32- 64-. .

, , , "" "" :

int var = 1;
int* addrOfVar = &var; // pointer to variable
uintptr_t pVar = (uintptr_t)&a;
uintptr_t pVar2 = reinterpret_cast<uintptr_t>(&dummy); // alternative cast
0

All Articles