📄 example.cc
字号:
// file: $isip/doc/examples/class/system/system_example_00/example.cc// version: $Id: example.cc,v 1.3 2000/12/17 16:43:26 hamaker Exp $//// isip include files//#include <File.h>#include <Console.h>#include <String.h>// main program starts here:// this program emulates the tool 'cat -n' by printing a file line by// line and prepending the line number to the output.//int main() { // declare local variables for the File object and the filename // File input; String temp_file(L"./input.text"); // return an error if the file cannot be opened. note that if the file // is not found, the File class will poll for the file. the number of // times to poll and the time between attempts can be adjusted through // the File::setOpenRetry method // if (!input.open(temp_file, File::READ_ONLY)) { Error::handle(input.name(), L"open", Error::IO, __FILE__, __LINE__); } // declare strings to be used for reading and writing // String line_num; String buf; // initialize the line count // long line_count = 0; // read in a line of text with the File::get method and increment the // line count // while (input.get(buf)) { line_count = line_count + 1; // build the output string first assigning a string from an integral // type and then inserting the line number information in front of // the buffer read from the file. // line_num.assign((long)line_count); line_num.concat(L" "); buf.insert(line_num, 0); // print the string to the console // Console::put(buf); } // close the file // input.close(); // exit gracefully // Integral::exit();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -