Skip to content

Instantly share code, notes, and snippets.

@henriquesebastiao
Created April 1, 2024 13:37
Show Gist options
  • Save henriquesebastiao/76f6094da2dfb955c7ebb385c1f91e07 to your computer and use it in GitHub Desktop.
Save henriquesebastiao/76f6094da2dfb955c7ebb385c1f91e07 to your computer and use it in GitHub Desktop.
Testes com ponteiros em C.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
void main() {
int numero = 10;
int *ponteiro = &numero;
printf("%d\n", numero);
printf("%d\n", &numero);
printf("%d\n", ponteiro);
printf("%d\n", &ponteiro);
printf("%d\n", *ponteiro);
// Output
// 10 (valor da variavel numero)
// -1692088420 (endereço de memória onde está a veriável número)
// -1692088420 (o valor do ponterio é endereço de memória onde está o valor da variável cujo a qual ele referencia)
// -1692088416 (endereço de memória do próprio ponteiro)
// 10 (valor da variavel que o ponteiro está referenciando)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment