3

コードの何が問題になっていますか? ファイルから入力を取得したい (最初の 1 つの文字列、次に char 、次に int)。ファイル全体に必要です。これが私のコードです。これは私にとても苦痛を与えています。私に何ができる?私を助けてください。

//file handling
//input from text file
//xplosive


#include<iostream>
#include<fstream>
using namespace std;
ifstream infile ("indata.txt");

int main()
{
    const int l=50;
    //string t_ques;
    char t_ques[l];
    char t_ans;
    int t_time_limit;


    while(!infile.eof())
    //while(infile)
    {
        infile.getline(t_ques,l);
        //infile >> t_ans ;
        infile.get(t_ans);
        infile >> t_time_limit;

        cout << t_ques << endl;
        cout << t_ans << endl;
        cout << t_time_limit << endl;
    }




    return 0;
}

私のindata.txtファイルが含まれています

what is my name q1?
t
5
what is my name q2?
f
3
what is my name q3?
t
4
what is my name q4?
f
8

out put should be the same.
but my while loop don't terminate.
4

2 に答える 2