So, the program will scan what user type in like "ENQUEUE A" or "DEQUEUE" or "Ctrl^Z". While "Ctrl^Z" will stop the program.
'Cause "ENQUEUE A" have a space, I use while(scanf("%[^\n]", input)==EOF) to keep user typing in until "ctrl^Z" being typed.
But the result is the while loop will automatically start even the user not typing anything, and the loop will keep going forever.
int main()
{
char input[9];
puts("\nEnter ENQUEUE (member) or DEQUEUE to process, or Ctrl^Z to stop
program:");
while(scanf("%[^\n]", input)!=EOF)
{
puts("processing");
}
}
Thanks for anyone who answering, and sorry for my bad English.
This program intend to deal some Queue issue. And user can type like "ENQUEUE A" to enqueue this letter into queue, or "DEQUEUE" to dequeue it.
The while loop I have now is just for debug test, so it only have one puts function.
The user can keep doing these action until they enter Ctrl+Z. But in my program, even the user hasn't type anything, the loop just automatically going on an infinite loop. And it even not let user type anything.