Encoders
Hub for Computer Whizzes Register to join us

Encoders > More... > C > Program

/* Program to copy its input to its output, replacing each string of
   one or more blanks by a single blank. */

#include <stdio.h>

#define IN 	1
#define OUT    0

main()
{
	int c,state;
	state=OUT;
	while((c=getchar())!=EOF)
		if(c!=' '&&c!='\t')
		{
			state=IN;
			putchar(c);
		}
		else if(state==IN)
		{
			state=OUT;
			putchar(' ');
		}
	printf("\n");
}