Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
indexing array in function from the pointer of some element

Imagine some array

uint8_t var[5] = {1,2,3,4,5};

so var will be pointer to the first element of this array, and

uint 8_t* a=var;
b=a[3]

and

b=var[3]

will give the same result.

But will

a = &var[2];
b = a[1];

and

b=var[3];

be same?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

After this assignment

a = &var[2];

that is the same as

a = var + 2;

due to the implicit conversion of the array designator to a pointer to its first element the pointer a points to the element var[2].

So a[0] yields var[2] and a[1] yields var[3].

Pay attention to that the subscript operator a[i] is evaluated like *( a + i ).

So you have a[1] is equivalent to *( a + 1 ) that is in turn equivalent to *( var + 2 + 1 ) that is to *( var + 3 ).

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda