Code:
#include <ctype.h>
#include <stdio.h>
#include <string.h>
static char *rev(char *to, const char *from)
{
const char *endp = from + strlen(from);
char *save = to;
while (endp > from)
*to++ = *--endp;
*to = '\0';
return save;
}
static int read(char *to, size_t n)
{
int c;
n--;
while ((c = getchar()) != EOF && !isspace(c))
if (n) {
*to++ = c;
n--;
}
*to = '\0';
return c;
}
int main(void)
{
char first[35], last[35];
char rfirst[sizeof first], rlast[sizeof last];
while (read(first, sizeof first) != EOF
&& read(last, sizeof last) != EOF)
printf("%s %s\n", rev(rfirst, first), rev(rlast, last));
return 0;
}