📄 readlower.h
字号:
//: C26:readLower.h
// From Thinking in C++, 2nd Edition
// Available at http://www.BruceEckel.com
// (c) Bruce Eckel 1999
// Copyright notice in Copyright.txt
// Read a file into a container of string,
// forcing each line to lower case.
#ifndef READLOWER_H
#define READLOWER_H
#include "../require.h"
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cctype>
inline char downcase(char c) {
using namespace std; // Compiler bug
return tolower(c);
}
std::string lcase(std::string s) {
std::transform(s.begin(), s.end(),
s.begin(), downcase);
return s;
}
template<class SContainer>
void readLower(char* filename, SContainer& c) {
std::ifstream in(filename);
assure(in, filename);
const int sz = 1024;
char buf[sz];
while(in.getline(buf, sz))
// Force to lowercase:
c.push_back(string(lcase(buf)));
}
#endif // READLOWER_H ///:~
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -