Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. // Es una buena práctica definir el prototipo de las funciones aquí arriba
  4. // ojo: sólo el prototipo, no el cuerpo
  5. int incrementar(int *numero);
  6.  
  7. int main(int argc, char const *argv[])
  8. {
  9. int numero = 10;
  10. printf("Antes de llamar a la funcion, numero es %d\n", numero);
  11.  
  12. // Con el operador & obtenemos la dirección de numero
  13. incrementar(&numero);
  14. printf("Despues de llamar a la funcion, numero es %d", numero);
  15. }
  16.  
  17. // Ahora sí definimos la función con todo y cuerpo
  18. //Notar el * antes de numero
  19. int incrementar(int *numero){
  20. //Incrementar en 1
  21. (*numero) = (*numero) + 1;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement