[ create a new paste ] login | about

Link: http://codepad.org/dAcdN04B    [ raw code | fork ]

ninwa - C++, pasted on Sep 8:
/* The C Programming Language,
   solution to Exercise 1-9 */

#include <stdio.h>

/* A small application which copys our input to our output
   but reduces all series of blanks in our input to only
   one blank per series in our output. */

main()
{
	int c;
	int noMoreBlanks = 0;

	while ((c = getchar()) != EOF ){
		if (c == ' '){
			if (noMoreBlanks)
				continue;
			else{
				putchar(c);
				noMoreBlanks = 1;
			}
		}
		else{
			if (noMoreBlanks)
				noMoreBlanks = 0;
			
			putchar(c);
		}
	}
}


Create a new paste based on this one


Comments: