Advertisement
Guest User

Untitled

a guest
Jun 28th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cctype>
  4. #include <cstring>
  5. using namespace std;
  6. const int SIZE = 80;
  7.  
  8. int sentenceCounter(int array[SIZE]) {
  9. int count = 0;
  10. for (int i = 0; i <= sizeof(array); i++) {
  11. if (array[i] = '.') {
  12. count++;
  13. }
  14. } return count;
  15. }
  16. int spaceCounter(int array[SIZE]) {
  17. int counter = 0;
  18. for (int i = 0; i <= sizeof(array); i++){
  19. if (isblank(array[i]))
  20. counter++;
  21.  
  22. }
  23. return counter;
  24. }
  25.  
  26. int puntctuationCounter(int array[SIZE]) {
  27. int counting = 0;
  28. for (int i = 0; i <= sizeof(array); i++) {
  29. if (ispunct(array[i]))
  30. counting++;
  31.  
  32. }return counting;
  33. }
  34. int numberCounter(int array[SIZE]) {
  35. int counted = 0;
  36. for (int i = 0; i <= sizeof(array); i++) {
  37. if (isdigit(array[i])) {
  38. counted++;
  39. }
  40. }
  41. return counted;
  42. }
  43. int wordCounter(int array[SIZE]) {
  44. int countt = 0;
  45. for (int i = 0; i <= sizeof(array); i++) {
  46. if (array[i] == ' ' && array[i] == '\0') {
  47. countt++;
  48. }
  49. }return countt;
  50. }
  51.  
  52. int lineCounter(int array[SIZE]) {
  53. int countedd = 0;
  54. for (int i = 0; i <= sizeof(array); i++) {
  55. if (array[i] == '\0') {
  56. countedd++;
  57. }
  58. }return countedd;
  59. }
  60.  
  61.  
  62.  
  63. int main() {
  64. int number, sentence, space, punct, word,line;
  65. char array = SIZE;
  66.  
  67. int i = 0;
  68. ifstream file_reader("havenotcreatedthefileyet.txt");
  69. while (is.get(file_reader, array)) {
  70. for (int i = 0; i <= SIZE; i++) {
  71.  
  72.  
  73. }
  74.  
  75. number = numberCounter();
  76. sentence = sentenceCounter();
  77. space = spaceCounter();
  78. punct = puntctuationCounter();
  79. word = wordCounter();
  80. line = lineCounter();
  81.  
  82. cout << "Number of Numbers : " << number << endl;
  83. cout << " Number of Sentences : " << sentence << endl;
  84. cout << "Number of Spaces : " << space << endl;
  85. cout << " Number of Punctuation marks : " << punct << endl;
  86. cout << "Number of Words : " << word << endl;
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93. }return 0;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement