Fonction qui ne marche pas sans variable globale
voila mon probleme je test une fonction avec une variable global voici mon code
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| #include <stdio.h>
#include <stdlib.h>
int resultat = 5;
void function(int nombre);
int main()
{
function(resultat);
printf("%d", resultat);
return 0;
}
*
void function(int nombre)
{
resultat = nombre * 3;
} |
il marche bien ca affiche bien 15
mais quand je passe en parametre a la fonction "resulta" ca ne marche pas voici le code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| #include <stdio.h>
#include <stdlib.h>
int resultat = 5;
void function(int resultat);
int main()
{
function(resultat);
printf("%d", resultat);
return 0;
}
void function(int resultat)
{
resultat = resultat * 3;
} |
ca affiche 5 , comment c'est possible je suis perdu , eclairer moi un peu je ne comprend pas et merci pour votre aide.