Posted By

sebastianf on 01/31/10


Tagged

replace blank getchar putchar


Versions (?)

replace more blanks with one blank


 / Published in: C
 

  1. #include <stdio.h>
  2. int main (int argc, const char * argv[]){
  3. int c, blank=0;
  4.  
  5. c=getchar();
  6. while(c != EOF){
  7. if(c==' '&&blank==0){
  8. blank++;
  9. putchar(c);
  10. c=getchar();
  11. }
  12. elseif(c==' '&&blank!=0){
  13. c=getchar();
  14. }
  15. else{
  16. putchar(c);
  17. c=getchar();
  18. blank=0;
  19. }
  20. }
  21. }

Report this snippet  

You need to login to post a comment.