hamaXD

CPT lab04-01

Sep 12th, 2017
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. //main.c
  2. #include<stdio.h>
  3. #include<string.h>
  4. void replace_space(char *s, char c);
  5.  
  6. int main(){
  7.     int i=0,len =0;
  8.     char s[100],ch;
  9.    
  10.     gets(s); fflush(stdin);
  11. //  printf("%s\n",s);
  12. //  scanf("%s",&s[0]); fflush(stdin);
  13. //  printf("%s\n",s);
  14.     scanf("%c",&ch);
  15. //  printf("%c\n",ch);
  16.     len = strlen(s);
  17.     while(i<len){
  18.         if(s[i]==' '){
  19.             replace_space(&s[i],ch);
  20.         }
  21.         i++;
  22.     }
  23.     printf("%s",s);
  24.     return 0;
  25. }
  26.  
  27. void replace_space(char *s, char c){
  28.     *s = c ;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment