I don't know why the code
scanf("%c",&eingabe);
everytime overleaps.
i try it with getchar too but same problem again.
I use linux but execute the code with xterm.
Anyone can help me?
#include <stdio.h>
#include <stdlib.h>
int main()
{
int z1,z2,erg=0;
char eingabe;
while(1){
printf("Geben Sie die erste Zahl an: ");
scanf("%d",&z1); //works
fflush(stdin); //clear
printf("\nGeben Sie die zweite Zahl an: ");
scanf("%d",&z2); //works
fflush(stdin);//clear
erg=z1*z2; //works
printf("\n%d * %d = %d",z1,z2,erg); //works
printf("\n");
printf("#######################");
printf("\n");
printf("Weiter = W\n");
printf("Stop = P\n");
printf("Eingabe: ");
scanf("%c",&eingabe); //this is the line with the problem
fflush(stdin); //clear
switch(eingabe){
case 'w':
system("clear");
break;
case 'p':
system("exit");
break;
default:
printf("\nEingabe Unbekannt");
}
printf("\n");
}
return 0;
}