请更具体。你可以这样做
#include <stdio.h>
// only if you dont want to wait for enter each get
#include <termios.h>
#include <unistd.h>
int main ()
{
char c = 0;
// only if you dont want to wait for enter each get
struct termios newtty;
tcgetattr (0, &newtty);
newtty.c_lflag &= (~ICANON);
tcsetattr (0, TCSANOW, &newtty);
puts ("start\n");
do {
if(c == 0)
c=getchar();
switch(c)
{
case '1':
c=getchar();
if(c == '\n')
putchar ('1');
else
continue;
c = 0;
break;
case '0':
case '\t':
c=getchar();
if(c == '\n')
putchar ('0');
else
continue;
c = 0;
break;
case '\n':
putchar ('0');
c = 0;
break;
default:
c = 0;
continue;
}
} while (1);
return 0;
}