wcypierre

[c++]delete char and display the remaining words

Feb 24th, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. char str[20],deletechar,reStr[20]="";
  6. cout<<"Enter String:\n";
  7. cin>>str;
  8.  
  9. cout<<"Enter Character which you want to delete:\n";
  10. cin>>deletechar;
  11. //write your logic here
  12.  
  13. for(int index = 0, str_index = 0; index < 20; index++)
  14. {
  15. if(str[index] != deletechar)
  16. {
  17. reStr[str_index] = str[index];
  18. str_index++;
  19. }
  20. }
  21.  
  22. //end
  23. cout<<"Result String is:\n";
  24. cout<<reStr;
  25.  
  26.  
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment