I figured it out, I am still not sure why but the order of my if
statement was causing the issue.
The working code looks like this:
#include <stdio.h>
int main()
{
int c;
while ((c = getchar()) != EOF)
{
if (c == ' ')
{
putchar(c);
while ((c = getchar()) == ' ')
{
}
}
putchar(c);
}
}
Levs-iMac:ch1 levlaz$ ./a.out
thank you randell
thank you randell
THANK YOU RANDELL !!!
THANK YOU RANDELL !!!