cblc/aulas/06-vetores/vetores.txt

27 lines
1.5 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

VETORES
=======
- Um dos tipos compostos da linguagem C.
- Estruturas de dados que agrupam valores de mesmo tipo.
- O nome do vetor é o endereço de seu primeiro elemento.
- Não confunda a sintaxe de vetores com o conceito de vetor!
NOME + ÍNDICE (× TIPO) ==> NOME[ÍNDICE]
vetor+0 vetor+1 vetor+2 vetor+3 vetor+4 (*)
↓ ↓ ↓ ↓ ↓
+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
int vetor[4] = {1, 2, 3, 4}; ---> | 01 | 00 | 00 | 00 | 02 | 00 | 00 | 00 | 03 | 00 | 00 | 00 | 04 | 00 | 00 | 00 |
+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
vetor = endereço na memória ↑ ↑ ↑ ↑ ↑
Total de 16 bytes +----- 4 bytes -----+----- 4 bytes -----+----- 4 bytes -----+----- 4 bytes -----+
↑ ↑
&vetor+0 &vetor+1 (*)
(*) Problema: acesso fora dos limites do vetor!