Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1412 connectés 

  FORUM HardWare.fr
  Programmation
  C++

  float point error : domain

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

float point error : domain

n°1034246
Maxi-mome
Posté le 04-04-2005 à 13:22:08  profilanswer
 

Slt @ tous, avec un pote on est sur un projet en C++ et on a un message d'erreur à  
 
l'execution "floating point error: domain", et en fait qd on déclare nos réels en entier,  
 
ça marche !! ms nous on a besoin de réels !!!!
 
struct Identite
{
 char Nom[Max_Chaine];
 char Prenom[Max_Chaine];
 int Age;
 char Statut;
};
 
struct Date
{
 int Jour;
 int Mois;
 int Annee;
};
 
struct Client
{
 Identite Identite;
 Date Date;
 int Montant_Emprunte;
 float Taux;
 int Duree_Emprunt;
 float Montant_Interet;
};
 
// suite
 
void Telecharger_Fichier(int &NBCLI)
{
 int i, k;
 char NomFic[Max_Chaine];
 Client TabClient[Max_Chaine];
 cout<<"\Entrez le chemin absolu du fichier a telecharger svp : ";
 cin>>NomFic;
 ifstream ficent(NomFic);
 if(ficent==FAUX)
 {
  cout<<"\nOuverture impossible : fichier inexistant ";
  exit(-1);
 }
 else
 {
  i=0;
  ficent>>TabClient[i].Identite.Nom;
  ficent>>TabClient[i].Identite.Prenom;
  ficent>>TabClient[i].Identite.Age;
  ficent>>TabClient[i].Identite.Statut;
  ficent>>TabClient[i].Date.Jour;
  ficent>>TabClient[i].Date.Mois;
  ficent>>TabClient[i].Date.Annee;
  ficent>>TabClient[i].Montant_Emprunte;
  ficent>>TabClient[i].Taux;
  ficent>>TabClient[i].Duree_Emprunt;
  ficent>>TabClient[i].Montant_Interet;
  while(ficent.eof()==FAUX)
  {
   i++;
   ficent>>TabClient[i].Identite.Nom;
   ficent>>TabClient[i].Identite.Prenom;
   ficent>>TabClient[i].Identite.Age;
   ficent>>TabClient[i].Identite.Statut;
   ficent>>TabClient[i].Date.Jour;
   ficent>>TabClient[i].Date.Mois;
   ficent>>TabClient[i].Date.Annee;
   ficent>>TabClient[i].Montant_Emprunte;
   ficent>>TabClient[i].Taux;
   ficent>>TabClient[i].Duree_Emprunt;
   ficent>>TabClient[i].Montant_Interet;
  }
  NBCLI=i;
  cout<<"\nIl y a "<<i<<" clients\n";
  for(k=0; k<i; k++)
  {
   cout<<TabClient[k].Identite.Nom<<" ";
   cout<<TabClient[k].Identite.Prenom<<" ";
   cout<<TabClient[k].Identite.Age<<" ";
   cout<<TabClient[k].Identite.Statut<<" ";
   cout<<TabClient[k].Date.Jour<<" ";
   cout<<TabClient[k].Date.Mois<<" ";
   cout<<TabClient[k].Date.Annee<<" "; // A COMPLETER CA MARCHE POOO
   cout<<TabClient[k].Montant_Emprunte<<" ";
   cout<<TabClient[k].Taux<<" ";
   cout<<TabClient[k].Duree_Emprunt<<" ";
   cout<<TabClient[k].Montant_Interet<<"\n";
  }
 }
 ficent.close();
}
 
 
QQn peut nous aider ?????????

mood
Publicité
Posté le 04-04-2005 à 13:22:08  profilanswer
 

n°1035332
LordHarryP​otter
Posté le 05-04-2005 à 10:01:26  profilanswer
 

Maxi-mome a écrit :

Slt @ tous, avec un pote on est sur un projet en C++ et on a un message d'erreur à  
 
l'execution "floating point error: domain", et en fait qd on déclare nos réels en entier,  
 
ça marche !! ms nous on a besoin de réels !!!! <-super mais çà te dit le message quand ? où dans le code ???
struct Client
{
 Identite Identite;
 Date Date;
 int Montant_Emprunte;
 float Taux; // <- perso je n'utilise jamais le type float mais le type double
 int Duree_Emprunt;
 float Montant_Interet; // <- idem
};
 
// suite
 
void Telecharger_Fichier(int &NBCLI)
{
  while(ficent.eof()==FAUX) // while( !ficent.eof() )
  {
   i++;
   ficent>>TabClient[i].Montant_Interet;
  }
 
  NBCLI=i;
  cout<<"\nIl y a "<<i<<" clients\n"; // !! il y a i+1 clients !!!
  for(k=0; k<i; k++)
  {
  }
 }
 ficent.close();
}


 
Cà n'a rien à voir avec ton problème mais quand  ta boucle while sort TabClient est un tableau de i+1 valeur (de 0 à i), donc quand tu fais ton for(k=0;k<i;k++) tu ne traite pas le dernier élément.
 
Je suis pas un pros des (iof)stream, mais j'ai pris l'habitude de faire un ficent.clear juste après avoir fait ficent.close().
 
Sinon pour ton problème peux tu dire où le compilo te met le message d'erreur.


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C++

  float point error : domain

 

Sujets relatifs
Warning a cause de Structures et Float...Server Error
SQL / Informix : Error 297CAST ERROR
[CSS] Astuce <div class="clr"> sur le float[CSS] Problème avec boite en float
ecrire un float dans un wxTextCtrl (wxWidgets)conversion d'un float en String avec java
[MySQL] Impossible de se connecter au serveur? Error 2003 ???Linker Error while emitting metadata
Plus de sujets relatifs à : float point error : domain


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR