Désolé, je n'ai pas trop le temps de regarder plus avant, simplement si tu ré-initialises à la même seconde tu obtiendras le même résultat sur le
rand suivant. Sortir le
srand et le faire (une seule fois) avant permet au moins d'éviter ce problème.
Du coup je suis étonné que ça ne change rien chez toi et j'ai fais un test rapide en tapant simplement :
Code:
1 2 3 4 5
| int main(void)
{
srand(time(NULL));
printf ("le res : %d\n",choi_position(0, 1, 0, 1));
} |
J'ai laissé ta fonction telle quelle (en enlevant seulement
srand -et
sleep par la même occasion-) et là plus de boucle infinie.
PS : ce topic devrait t'apporter un éclairage plus intéressant sur
rand :
http://www.developpez.net/forums/d12...-aleatoires-c/