Exercise 1.9 - Replace Continous blanks with a single blank


Write a program to copy its input to its output, replacing each string of one or more blanks by a single blank.



The essence of this program is, while reading the characters, if the last character that we encoutered is a blank, then we skip printing it.

if(lastc!=' ')

This means that if the last character is not a blank, only then print it. We store the last character in the lastc variable in the line lastc = c. For rest of the characters we simplying print it by putchar (c).