hello so this code is for drowing shapes the problem is when the traitement which is in the loop while is finished and is lanced again after the function showinterface it don't wait for getting the char and then it repeat that function and wait for getting the char this is the code :
int main ()
{ while (1)
{
fflush(stdin);
ShowInterface () ;
ch = GetNumber () ;
fflush(stdin);
switch (ch)
{
case '1':
printf ( " donner la largeur du carre ");
scanf ("%d" , &langeur_carre) ;
Drawing_shape (langeur_carre , langeur_carre) ;
printf (" \n ----------------------------------------------------- \n") ;
fflush(stdin);
break;
case '2':
printf ( " donner la largeur du rectangle ");
scanf ("%d" , &largeur_rect) ;
printf ( " donner la longeur du rectangle ");
scanf ("%d" , &langeur_rect) ;
Drawing_shape (largeur_rect ,langeur_rect) ;
printf (" \n ----------------------------------------------------- \n") ;
fflush(stdin);
break;
case '3':
exit(0);
}
}
and this is the output
-----------------------------------------------------
Bonjour Bienvenu !!
1-Dessiner un carré
2-Dessiner un rectangle
3-Quitter
-----------------------------------------------------
choisir le touche que vous convient : 1
donner la largeur du carre 3
###
# #
###
-----------------------------------------------------
-----------------------------------------------------
Bonjour Bienvenu !!
1-Dessiner un carré
2-Dessiner un rectangle
3-Quitter
-----------------------------------------------------
choisir le touche que vous convient :
-----------------------------------------------------
Bonjour Bienvenu !!
1-Dessiner un carré
2-Dessiner un rectangle
3-Quitter
-----------------------------------------------------
choisir le touche que vous convient : 1
As you see in the second time it don't get the char and even i don't touch any key
this the code of the function GetNumber :
char GetNumber ()
{
printf("choisir le touche que vous convient : ");
scanf ("%c" , &ch);
return (ch) ;
}