getline.cpp

来自「Thinking_in_C___2.rar」· C++ 代码 · 共 18 行

CPP
18
字号
//: C03:Getline.cpp
// From Thinking in C++, 2nd Edition
// at http://www.BruceEckel.com
// (c) Bruce Eckel 1999
// Copyright notice in Copyright.txt
// Stream input by lines
#include <iostream>
using namespace std;

int main() {
  char buf[100];
  char trash;
  while(cin.get(buf,100)) { // Get chars until '\n'
    cin.get(trash); // Throw away the terminator
    cout << buf << "\n";  // Add the '\n' at the end
  }
} ///:~

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?