Langage C, plantage sur boucle while
kalkos
Messages postés
3
Date d'inscription
Statut
Membre
Dernière intervention
-
kalkos Messages postés 3 Date d'inscription Statut Membre Dernière intervention -
kalkos Messages postés 3 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
je ne sais pas pourquoi mais mon programme plante a chaque fois qu'il doit aller dans une boucle while ("indiquer en dessous")
Pouvez vous m'aider a trouver pourquoi ?
Voici mes structures
typedef struct elem
{int value;
struct elem* prev;
struct elem* next;
}element;
typedef element* absvalue;
typedef struct
{ int sign;
absvalue abs;
}BigInteger;
BigInteger insert_tail (BigInteger S, int j, int r)
{
absvalue newel = (element*) malloc (sizeof(element));
newel->value = abs((j%10000+r)%10000);
newel->prev = NULL;
newel->next = NULL;
absvalue k = S.abs;
//c'est au niveau du while qui suis que vien le problème.\\
while (k->next != NULL)
{
k = k->next;
}
k->next = newel;
newel->prev = k;
return S;
}
je ne sais pas pourquoi mais mon programme plante a chaque fois qu'il doit aller dans une boucle while ("indiquer en dessous")
Pouvez vous m'aider a trouver pourquoi ?
Voici mes structures
typedef struct elem
{int value;
struct elem* prev;
struct elem* next;
}element;
typedef element* absvalue;
typedef struct
{ int sign;
absvalue abs;
}BigInteger;
BigInteger insert_tail (BigInteger S, int j, int r)
{
absvalue newel = (element*) malloc (sizeof(element));
newel->value = abs((j%10000+r)%10000);
newel->prev = NULL;
newel->next = NULL;
absvalue k = S.abs;
//c'est au niveau du while qui suis que vien le problème.\\
while (k->next != NULL)
{
k = k->next;
}
k->next = newel;
newel->prev = k;
return S;
}
A voir également:
- Langage C, plantage sur boucle while
- Langage ascii - Guide
- Langage binaire - Guide
- Plantage windows 10 - Guide
- Pascal langage - Télécharger - Édition & Programmation
- Xiaomi s'éteint tout seul et se rallume en boucle - Forum Xiaomi
4 réponses
Bonjour
Il nous manque l'initialisation de S. On peut supposer que S n'est jamais initialisé, S.abs non plus donc k->next provoque une erreur
Il nous manque l'initialisation de S. On peut supposer que S n'est jamais initialisé, S.abs non plus donc k->next provoque une erreur