Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. bool separador(char cosa)
  7. {
  8. if ((cosa >= 'a' && cosa <= 'z') || (cosa >= 'A' && cosa <= 'Z'))
  9. {
  10. return false;
  11. }
  12. return 1;
  13. }
  14.  
  15. int main()
  16. {
  17. char caracter , caracterProhibit;
  18. bool eraSeparador = 1;
  19. bool ignorar = 0;
  20. cout << "NOM DEL FITXER:" << endl;
  21. string fitxer;
  22. cin >> fitxer;
  23. ifstream arxiu;
  24. arxiu.open(fitxer.c_str());
  25. cout << "INTRODUEIX UN CARACTER:" << endl;
  26. cin >> caracterProhibit;
  27. if (arxiu.fail())
  28. {
  29. cout << "NO S'HA TROBAT EL FITXER";
  30. return 0;
  31. }
  32. cout << "TEXT RESULTANT D'ELIMINAR LES PARAULES QUE COMENCEN PER " << caracterProhibit << ":" << endl;
  33.  
  34. while (caracter != '!' )
  35. {
  36. eraSeparador = separador(caracter);
  37. arxiu.get(caracter);
  38. }
  39. if (caracter == caracterProhibit && eraSeparador){
  40. ignorar = 1;
  41. }
  42. if (separador(caracter) && !eraSeparador){
  43. ignorar = 0;
  44. }
  45. if (ignorar == 0){
  46. cout << caracter;
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement