zim22, еще это все в цикл завернуть чтоб для всех строк файла работало..ну или так например можно как вариант чтобы поизвращатся 
| Код | #include <fstream> #include <string> #include <cctype> #include <algorithm> #include <functional>
struct changeCase : std::unary_function<char, void> { void operator () (char& r) { if (isupper(r)) r = tolower( r ); else r = toupper( r ); } };
int main() { std::string text; std::ifstream in("file.txt"); std::ofstream out("result.txt");
while ( getline(in, text ) ) { std::for_each( text.begin(), text.end(), changeCase() ); out << text; } out.close(); in.close(); return 0; }
|
|