Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- #include<cctype>
- #include<sys/stat.h>
- #include <sys/types.h>
- #include<Windows.h>
- using namespace std;
- int main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- setlocale(LC_ALL, "Russian");
- ifstream file;
- char* filePathStr = new char[25000];
- struct stat b;
- wcout << "Введите полный путь до файла" << endl;
- cin >> filePathStr;
- file.open(filePathStr);
- while (stat(filePathStr, &b) != 0 || !file) {
- file.close();
- cout << "Что-то пошло не так. Введите полный путь до файла" << endl;
- cin >> filePathStr;
- file.open(filePathStr);
- }
- cout << endl << "Измененный файл:" << endl;
- while (!file.eof()) {
- char* line = new char[b.st_size + 1];
- file.getline(line, b.st_size + 1);
- int i = 0;
- int up = 1;
- while (line[i] != '\0') {
- if (line[i] == ' ') up = !up;
- line[i] = up ? toupper(line[i]) : tolower(line[i]);
- up = !up;
- i++;
- }
- cout << line << endl;
- }
- file.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment