Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #include<fstream.h>
  2. #include<conio.h>
  3. #include<string.h>
  4. #include<stdio.h>
  5. #include <ctype.h>
  6. void func()
  7. {
  8. char stream[80],name[100];
  9. int a = 0;
  10. cout << "Enter the name of the text file: " << endl;
  11. gets(name);
  12. cout << "Enter the sentence you want to insert in the file: ";
  13. gets(stream);
  14. ofstream fout(name);
  15. fout << stream;
  16. fout.close();
  17. ofstream copy("copy.txt");
  18. ifstream fin(name);
  19. cout << "nWords in copy.txt:" << endl;
  20. while(!fin.eof())
  21. {
  22. fin.getline(stream,80,' ');
  23. if(fin.eof())
  24. break;
  25. a = strlen(stream)-1;
  26. if(stream[a] == '.' || stream[a] == '?' || stream[a] == '!' || stream[a] == '"') //followed by punctuarion mark
  27. {
  28. if((isalpha(stream[a-1])) && !(tolower(stream[a-1]) == 'a'|| tolower(stream[a-1]) == 'e'|| tolower(stream[a-1]) == 'i'|| tolower(stream[a-1]) == 'o'|| tolower(stream[a-1]) == 'u'))
  29. {
  30. copy << stream << ' ';
  31. cout << stream << ' ';
  32. }
  33. }
  34. else if((isalpha(stream[a])) && !(tolower(stream[a]) == 'a'|| tolower(stream[a]) == 'e'|| tolower(stream[a]) == 'i'|| tolower(stream[a]) == 'o'|| tolower(stream[a]) == 'u'))
  35. {
  36. copy << stream << ' ';
  37. cout << stream << ' ';
  38. }
  39. }
  40. }
  41. void main()
  42. {
  43. clrscr();
  44. func();
  45. getch();
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement