probleme programme structuré.
Bonjour tout le monde
J'ai un probleme pour la réalisation d'un programme structuré en mode console.
Voici la structure
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#include <stdlib.h>
#include <stdio.h>
#ifndef struct_H
#define struct_H
#define taux 6.55957
struct type
{
int choix;
};
#endif |
Voici le main.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
#include <stdio.h>
#include <stdlib.h>
#include "struct.h"
int main(int argc, char *argv[])
{
preprog();
return 0;
} |
Voici le fichier choixConv.c
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
include "struct.h"
#include <stdlib.h>
#include <stdio.h>
struct type t;
void preprog()
{
Question();
}
int Question()
{
float sommeurro;
float sommefranc;
printf("Quel conversion voulez vous faire\n");
printf("\n");
printf("Entrer 1 pour convertir euro en francs\n");
printf("Entrer 2 pour convertir francs en euro\n");
t.choix = getchar();
switch (t.choix){
case '1':
Euro_F(sommeurro);
break;
case '2':
Francs_E(sommefranc);
break;
default:
printf("Erreur de saisie");
break;
}
return 0;
} |
Voici le fichier francs.c
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#include "struct.h"
#include <stdlib.h>
#include <stdio.h>
struct type t;
float Francs_E(float sommeurro)
{
float sommeconv;
printf("Entrer la somme a convertir\n");
sommeurro = getchar();
printf("Convertion en cours\n");
sommeconv = sommeurro / taux;
printf("Voici le resultat de votre conversion %f", sommeconv);
} |
Voici le fichier euro.c
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#include "struct.h"
#include <stdlib.h>
#include <stdio.h>
struct type t;
float Euro_F(float sommefranc)
{
float sommeconv;
printf("Entrer la somme a convertir\n");
sommefranc = getchar();
printf("Convertion en cour\n");
sommeconv = sommefranc * taux;
printf("Voici le resultat de votre conversion %f", sommeconv);
} |
Mon probleme est que rien ne fonctionne, je pense que cela vient du switch, quand je rentre un valeur, l'appli se ferme.
Cordialement
A bientôt