Alors voilà j'me suis fait un exercice bidon qui consisté à convertir un nombre en pourcentages en appliquant la formule mathématiques "Nombre x 100".
Du coup j'ai crée une fonction de type double qui effectue la conversion.
Puis quand j'utilise un scanf pour que l'utilisateur puisse lui même choisir le nombre à convertir en pourcentages via l'invite de commande sa marche:
Mais quand on saisis direct le nombre direct depuis l'IDE ba sa marche!
Merci d'avance.
Dans la page de manuel de scanf
f Matches an optionally signed floating-point number; the next pointer must be a pointer to float.
Ce qui t'intéresse c'est cette partie du manuel :
l Indicates either that the conversion will be one of d, i, o, u, x, X, or n and the next pointer
is a pointer to a long int or unsigned long int (rather than int), or that the conversion will be
one of e, f, or g and the next pointer is a pointer to double (rather than float).
Dans ton éditeur de texte tu passe bien 1.0 en double à ta fonction. Quand tu utilise scanf il fait une conversion chelou entre un float et un double. Pour scanner un double tu peux donc utiliser :
scanf ("%lf", &nombre);
J'essayerais plus tard cette méthode et je t'en dirais des nouvelles merci beaucoup de ta réponse!