- 文件读写
- 大小写转化
直接贴一下代码 -
#include <iostream> #include <fstream> #include <sstream> #include <string> #include <vector> #include <map> #include <cstdlib> #include <cstring> #include <algorithm> //using namespace std; int main(int argc, char *argv[]) { const int N = 1024; std::ifstream in(argv[1], std::ios::in); std::ofstream out(argv[2], std::ios::out); if (!in.is_open() || !out.is_open()) { std::cout << "open file wrong" << std::endl; exit(-1); } char line[N]; while(!in.eof()) { in.getline(line, N); std::istringstream strIO(line); std::string str; while (strIO >> str) { std::transform(str.begin(), str.end(), str.begin(), ::toupper); //transform(str.begin(), str.end(), str.begin(), ::tolower); std::cout << str << std::endl; out << str << std::endl; std::transform(str.begin(), str.end(), str.begin(), ::tolower); std::cout << str << std::endl; } } in.close(); out.close(); return 0; }
文件的读写以及大小写转换
最新推荐文章于 2022-06-14 10:40:36 发布