Advertisement
Guest User

Untitled

a guest
Oct 11th, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. #include <stdio.h>
  2. char *no_space(char *);
  3.  
  4. int main(void) {
  5.  
  6.   char *strin = "HELLO WORLD";
  7.  
  8.   printf("%s\n", strin);
  9.   printf("%s\n", no_space(strin));
  10.  
  11.   return 0;
  12. }
  13.  
  14. char *no_space(char *strin){
  15.  
  16.  int i = 0, c = 0;
  17.    
  18.     for ( ; strin [i] ; i++ ){
  19.      
  20.      if ( strin[i] != ' ' )
  21.        
  22.         strin[c++] = strin[i];
  23.  
  24.     }
  25.    
  26.   strin[c]= '\0';
  27.  
  28.  return strin;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement