I have a problem with scanf, when I run program scanf just gets [space], so I'm confused.
***
1 EnQ
2 DeQ
3 Print
4 Exit
enter your choice: 1
enter the char:
1 EnQ
2 DeQ
3 Print
4 Exit
.... Help me please.
***
1 EnQ
2 DeQ
3 Print
4 Exit
enter your choice: 1
enter the char:
1 EnQ
2 DeQ
3 Print
4 Exit
.... Help me please.
Code:
#include <stdio.h>
#include <string.h>
int n = 0;
char Q[8];
int tmp;
char *H = Q;
char *T = Q;
int count = 0;
int main(){
int choice;
menu:
printf("\n1 EnQ\n 2 DeQ\n 3 Print\n 4 Exit\n");
printf("Enter your choice:");
scanf("%d", &choice);
switch(choice){
case 1:{
EnQ();
goto menu;
}
case 2:{
DeQ();
goto menu;
}
case 3:{
Print();
goto menu;
}
case 4:
return 0;
}
return 0;
}
int EnQ(){
if(count == 0){
printf("Enter the Char:");
scanf("%c", &Q[n]);
n++;
count++;
} else if(count == 7)
printf("The array is full");
else if(n == 7){
n = 0;
printf("Enter the char:");
scanf("%c", &Q[n]);
count++;
T = Q[n];
n++;
}else{
printf("Enter the char:");
scanf("%c", &Q[n]);
n++;
count++;
}
tmp = n;
return 0;
}
Comment