I coded a simple program that pretends two users input random characters and the program tells you which user wrote what
#include <stdio.h>
int main(void)
{
int x;
char user;
char ch;
puts("type a character");
for(x = 0;x < 9; x++)
{
if(x%2 == 1)
{
user = 'x';
}
if(x%2 != 1)
{
user = 'y';
}
ch = getchar();
printf("user %c inputs %c\n",user,ch);
}
}
The output should look something like this:
type a character:
a
user y inputs a
type a character:
b
user x inputs b
type a character:
e
user y inputs b
but instead it looks like this:
type a character
a
user y inputs a
user x inputs
b
user y inputs b
user x inputs
c
user y inputs c
user x inputs
d
user y inputs d
user x inputs
e
user y inputs e
which means user x never gets to type a character