Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <fstream>
- #include <iostream>
- #include <string>
- using namespace std;
- int CountWords(string name);
- int CountLines(string name);
- int main()
- {
- setlocale(LC_ALL, "Russian");
- string fileText;
- string fileName = "Temp.txt";
- int symbCount = 0, wordCount = 0, stringCount = 0, paragraphCount = 0;
- ifstream fileWithText(fileName);
- if (!fileWithText.is_open()) {
- cout << "File cannot be opened" << endl;
- getchar();
- return 0;
- }
- cout << "File is opened" << endl;
- fileWithText.close();
- cout << "Количество слов: " << CountWords(fileName) << endl;
- cout << "Количество строк: " << CountLines(fileName) << endl;
- getchar();
- system("pause");
- return 0;
- }
- int CountLines(string name) {
- ifstream file(name);
- string temp;
- int count = 0;
- while (!file.eof()) {
- getline(file, temp);
- if (temp[0] == ' ')
- cout << "АБЗАЦ ЕСТЬ " << endl;
- count++;
- }
- return count;
- }
- int CountWords(string name) {
- ifstream file(name);
- string temp;
- int count = 0;
- cout << "text: " << endl;
- while (!file.eof()) {
- file >> temp;
- count++;
- }
- return count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement