?? numberphotos.cpp
字號:
//: C02:NumberPhotos.cpp
// From Thinking in C++, 2nd Edition
// Available at http://www.BruceEckel.com
// (c) Bruce Eckel 2000
// Copyright notice in Copyright.txt
// Find the marker "XXX" and replace it with an
// incrementing number whereever it appears. Used
// to help format a web page with photos in it
#include "../require.h"
#include <fstream>
#include <sstream>
#include <iomanip>
#include <string>
using namespace std;
int main(int argc, char* argv[]) {
requireArgs(argc, 2);
ifstream in(argv[1]);
assure(in, argv[1]);
ofstream out(argv[2]);
assure(out, argv[2]);
string line;
int counter = 1;
while(getline(in, line)) {
int xxx = line.find("XXX");
if(xxx != string::npos) {
ostringstream cntr;
cntr << setfill('0') << setw(3) << counter++;
line.replace(xxx, 3, cntr.str());
}
out << line << endl;
}
} ///:~
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -