in line 54 i have (Liste InsertionOperation(Liste L , Operation op)) Program received signal SIGSEGV
User 11658048
Posts
-
Exception in code C -
Exception in code CHello, This is my code. When i compile and execute it i have the following error:
1 [main] test 5952 exception::handle: Exception: STATUS_ACCESS_VIOLATION
722 [main] test 5952 open_stackdumpfile: Dumping stack trace to test.exe.sta
ckdump#include
#include
#includetypedef struct Date{
int J ;
int M ;
int A ;
} Date;typedef struct Operation{
char Obj[30];
float Mnt ;
Date Date_Tr ;
int Type_Tr ;
int Etat ;
} Operation;typedef struct Cellule{
Operation Info ;
struct Cellule *succ ;
} Cellule ;typedef Cellule * Liste ;
int EgaliteDates(Date d1 , Date d2)
{
if ((d1.J==d2.J) && (d1.M==d2.M) && (d1.A==d2.A))
return 0;
else
{
if ((d1.A>d2.A) || ((d1.A==d2.A) && (d1.M>d2.M)) || (((d1.A==d2.A) && (d1.M==d2.A) && (d1.J==d2.J))))
return 1;
else
return 2;
}
}
Liste InsertionOperation(Liste L , Operation op)
{Liste temp; Liste pred; Liste element; element = malloc(sizeof(Liste)); element->Info = op; element->succ = NULL; if(L == NULL) { L=element; } else { if (EgaliteDates(L->Info.Date\_Tr,op.Date\_Tr)==2) { element->succ= L; L=element; } else { temp=L; pred=L; while((temp->succ != NULL) && (EgaliteDates(temp->Info.Date\_Tr,op.Date\_Tr)<2)) { pred=temp; temp = temp->succ; } element->succ=temp->succ; pred->succ = element; } } return L;
}
void afficherListe(Liste L)
{
Cellule *tmp = L;
int i=0;
while(tmp != NULL)
{
i++;
printf("Objet %d : %s, montant: %f, date : %d %d %d, type: %s\n", i,tmp->Info.Obj,tmp->Info.Mnt,tmp->Info.Date_Tr.J,tmp->Info.Date_Tr.M,tmp->Info.Date_Tr.M,tmp->Info.Type_Tr,tmp->Info.Etat);
tmp = tmp->succ;
}
}void RechercheDate(Liste L, Date minDate , Date maxDate )
{
Cellule *tmp = L;
printf("liste des objets entre %d/%d/%d et %d/%d/%d: \n",minDate.J,minDate.M,minDate.A,maxDate.J,maxDate.M,maxDate.A);
while(tmp != NULL)
{
if ((EgaliteDates(tmp->Info.Date_Tr , maxDate)<2) && (EgaliteDates(minDate,tmp->Info.Date_Tr)<2))
printf("Objet : %s, montant: %f, date : %d %d %d, type: %s\n",tmp->Info.Obj,tmp->Info.Mnt,tmp->Info.Date_Tr.J,tmp->Info.Date_Tr.M,tmp->Info.Date_Tr.M,tmp->Info.Type_Tr,tmp->Info.Etat);
tmp