#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cstring> // 必要な場合に文字列処理の関数を利用

// 例として3つのフィールドを持つ構造体を定義します
struct Person {
    char name[20];
    int age;
    char gender[10];
};

int main() {
    std::vector<Person> people; // Person構造体の配列を作成

    // ファイルからデータを読み込む
    std::ifstream infile("data.txt"); // data.txtは読み込むファイルの名前です

    if (!infile) {
        std::cerr << "ファイルを開けませんでした" << std::endl;
        return 1;
    }

    // 1行ずつファイルを読み込み、構造体に格納します
    Person person;
    while (infile >> std::setw(20) >> person.name >> person.age >> std::setw(10) >> person.gender) {
        people.push_back(person);
    }

    // データを表示して確認します
    for (const auto& p : people) {
        std::cout << "名前: " << p.name << ", 年齢: " << p.age << ", 性別: " << p.gender << std::endl;
    }

    infile.close(); // ファイルを閉じます
    return 0;
}