私はC++にまったく慣れておらず、以下の構造の形式でテキストファイルにレコードを書き込む方法を模索しています。
struct user {
    int id;
    char username [20];
    char password [20];
    char name [20];
    char email [30];
    int telephone;
    char address [70];
    int level;
}; 
これまでのところ、うまく書き込むことができますが、レコード数を計算する方法がわからないため、ID番号を増やすことなく、データをファイルに書き込んだ後のファイルは次のようになります。
1 Nick pass Nick email tele address 1
1 user pass name email tele address 1
1 test test test test test test 1
1 user pass Nick email tele addy 1
1 nbao pass Nick email tele 207 1
次のコードを使用します。
ofstream outFile;
outFile.open("users.dat", ios::app);
// User input of data here
outFile << "\n" << 1 << " " << username << " " << password << " " << name << " "
        << email << " " << telephone << " " << address  << " " << 1;
cout << "\nUser added successfully\n\n";
outFile.close();
では、挿入時に各レコードの値をインクリメントするにはどうすればよいですか?また、ファイル内の特定のレコードをターゲットにするにはどうすればよいですか?
編集:私は各行を表示できる限り持っています:
  if (inFile.is_open())
    {
    while(!inFile.eof())
    {
    cout<<endl;
    getline(inFile,line);
    cout<<line<<endl;
    }
    inFile.close();
    }