Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

179
Vistas
Why is the Dereference operator used to declare pointers?

Why is the * used to declare pointers?

It remove indirection, but doesn't remove any when you declare a pointer like int *a = &b, shouldn't it remove the indirection of &b?

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

Many symbols in C and C++ are overloaded. That is, their meanings depend on the context where they are used. For example, the symbol & can denote the address-of operator and the binary bitwise AND operator.

The symbol * used in a declaration denotes a pointer:

int b = 10;
int *a = &b,

but used in expressions, when applied to a variable of a pointer type, denotes the dereference operator, for example:

printf( "%d\n", *a );

It also can denote the multiplication operator, for example you can write:

printf( "%d\n", b ** a );

that is the same as

printf( "%d\n", b * *a );

Similarly, the pair of square braces can be used in a declaration of an array, like:

int a[10];

and as the subscript operator:

a[5] = 5;
over 4 years ago · Santiago Trujillo Denunciar

0

Any time you have a pointer declaration with initialization like this:

type *x = expr;

it is equivalent to the separate initialization followed by assignment:

type *x;
x = expr;

It is not equivalent to

type *x;
*x = expr;      /* WRONG */
over 4 years ago · Santiago Trujillo Denunciar

0

It's part of the declaration, so it's not a dereference operator at all. Yet it still means the same thing.

int *a

can be read as

The value pointed by a is an int.

just like

printf("%d\n", *a);

can be read as

Print the value pointed by a.

See this answer to Correct way of declaring pointer variables in C/C++ for a bit on background on this.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda