Just thought I'd share mine since I haven't seen it in this topic yet.
#include <stdio.h>
int main(void) {
char x[3];
while(atoi(gets(x))!=42)puts(x);
return 0;
}
Alternatively with fgets() and fputs():
#include <stdio.h>
int main(void)
{
char x[4];
while (atoi(fgets(x,4,stdin))!=42)
{
fputs(x,stdout);
}
return 0;
}