1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

c++で標準入力から1行毎に読み込む

Posted at

スクリプト系言語たとえば、python等でテキスト、データ処理をする場合に自分は結構やる方法で、標準入力からEOFまで1行単位にレコードを読んで行くというコードが、どうもc++でちゃんと記述されているページあまり見つからなかったので備忘録的に記載しておく。

#include <iostream>
#include <string>
using namespace std;
int main(){
  string buff;
  while(getline(cin, buff)){
    // なにかしたい場合ここで処理する
    cout << "[読み込んだデータ]" << buff << endl; 
  }
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?