replace more blanks with one blank


/ Published in: C
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.