ファイルから、生徒の名前、父親の名前、ロール番号、年齢の 4 つのデータ要素を読み取る必要があります。入力ファイル ストリームとして inps を使用し、出力データ ストリームとして outs を使用しています。入力ファイルに 10 個のデータ セットがあります。しかし、このプログラムは最初のデータセットのみを出力ファイルに書き込み、残りの 9 セットを無視します。この問題に対するいくつかの提案をお願いします。
string line;
int data;
while (inps) {
getline(inps,line); //read from file and put in line
s1.setName(line);
getline(inps,line);
s1.setFatherName(line);
inps>>data;
s1.setRollNo(data);
inps>>data;
s1.setAge(data);
outs.open("output",ios::app);
outs<<"Student name: "<<s1.getName()<<endl<<"Father’s name: "
<<s1.getFatherName()<<endl;
outs<<"Roll number: "<<s1.getRollNo()<<endl<<"Age: "
<<s1.getAge()<<endl<<endl;
outs<<"============================================================="
<<endl<<endl;
}
inps.close();
//write in output file
outs.close();