Created
July 26, 2012 23:29
-
-
Save renatoargh/3185230 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void alterarValor(int* x){ //repare nesta linha, recebemos um endereço | |
| *x = *x + 2; | |
| } | |
| int main(){ | |
| int x = 4;//x armazenada em `stack` | |
| int *endereco_de_x = &x; | |
| printf("x está armazenada em %p \n\n", endereco_de_x); | |
| //x está armazenada em 0x7fff69032c24 | |
| printf("Valor inicial de x: %i \n", x); | |
| alterarValor(endereco_de_x); //aqui passamos o endereço | |
| printf("Valor de x: %i >>> alterado com sucesso!!!", x); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment