Advertisement
apl-mhd

charcterCopyAndReplace

Oct 18th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void findAndReplace(char str2[30],char ch){
  5.     int n;
  6.  
  7.  
  8.     for(n =0; str2[n] != '\0';  n++ ){
  9.  
  10.  
  11.         if(str2[n] == ch ){
  12.  
  13.             str2[n] = '#';
  14.  
  15.         }
  16.     }
  17.  
  18.     printf("your replace string = %s \n", str2);
  19.  
  20.  
  21.  
  22. }
  23.  
  24. int main()
  25. {
  26.    printf("enter your string");
  27.  
  28.    char name[30], ch;
  29.     printf("enter string\n");
  30.  
  31.     gets(name);
  32.  
  33.     printf("enter charter\n");
  34.     scanf("%c", &ch);
  35.  
  36.     findAndReplace(name, ch);
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement