Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
C++ を使用してプログラムを実装していますが、入力ファイルから次の行を取得する際に問題があります。私が使用した:
const MAX 300; char oneline[MAX]; ifstream in; in.open("input.txt); in.getline(oneline,MAX);
この関数getlineは常にファイルの最初の行を取得します。問題は、ファイルの次の行を取得するにはどうすればよいかということです。
getline
std::string line; while(in.good()) { getline(in, line); //do something with line }
C++ を使用しているため、std::string を使用して行を読み取る必要があります。
while (getline(in,line,'\n')){ //do something with line }