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

I guess it very simple but I tried many combinations ... I managed to do this program last year it was by chance I guess because I cant do it now , but I failed on the 1-10 when I checked the answers from internet I saw that commands were used which wasnt mentioned at all in the program till 22nd page ... that ........ed me off and then I left the book now I started again because I am thinking there shall be many ways to do a program and surely there would be solutions with the mentioned commands till 22nd , right now I sucked at this , gonna read the last paragraphs again and continue trying it in this time I would appreciate any suggestions from you and here is my idea to the program :

If there is more than one space convert all to a single space and continue ...

here is the basic i/o code from K&R :

Code:
#include <stdio.h>
/* copy input to output; 1st version */
main()
  {
  int c;
  c = getchar();
  
  while (c != EOF) {
  putchar(c);
  c = getchar();
  }
}
P.S.: I am a complete beginner.