Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 7, 2019 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/52d2c198b7c05c37edeccd4281e99ad5 to your computer and use it in GitHub Desktop.
Save parzibyte/52d2c198b7c05c37edeccd4281e99ad5 to your computer and use it in GitHub Desktop.
#include<stdio.h>
// Es una buena práctica definir el prototipo de las funciones aquí arriba
// ojo: sólo el prototipo, no el cuerpo
int incrementar(int *numero);
int main(int argc, char const *argv[])
{
int numero = 10;
printf("Antes de llamar a la funcion, numero es %d\n", numero);
// Con el operador & obtenemos la dirección de numero
incrementar(&numero);
printf("Despues de llamar a la funcion, numero es %d", numero);
}
// Ahora sí definimos la función con todo y cuerpo
//Notar el * antes de numero
int incrementar(int *numero){
//Incrementar en 1
(*numero) = (*numero) + 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment