Skip to content

Instantly share code, notes, and snippets.

@fbarrios
Created May 14, 2017 17:44
Show Gist options
  • Save fbarrios/2ffcaff1b0889587b20bff7472641f72 to your computer and use it in GitHub Desktop.
Save fbarrios/2ffcaff1b0889587b20bff7472641f72 to your computer and use it in GitHub Desktop.
Dos formas de devolver un valor en C
// Forma #1: por valor de retorno
int obtener_valor()
{
return 4;
}
int main()
{
int x = obtener_valor();
// Uso el valor de x.
return 0;
}
// Forma #2: por referencia de parámetro
void obtener_valor(int* x)
{
*x = 4;
}
int main()
{
int x;
obtener_valor(&x);
// Uso el valor de x.
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment