daiki8は片付けができない

片付けしないと

iniの値をmapで管理

#include <Windows.h>
#include <iostream>
#include <array>
#include <vector>
#include <string>
#include <map>
#include <sstream>


int main()
{
    const std::string filePath = ".\\test.ini";

    std::array<char, 1024> buf; // vectorだと怒られる
    ::GetPrivateProfileSection("SectionA", &buf.front(), static_cast<DWORD>(buf.size()), filePath.c_str());

    bool is_key = true;
    std::map<std::string, std::string> m;
    std::string k;
    std::string v;
    for (const auto& c : buf) {
        if (c == '=') {
            is_key = false;
            continue;
        }
        if (c == '\0') {
            m.insert({ k, v });
            is_key = true;
            k.clear();
            v.clear();
            continue;
        }
        if (is_key) k.push_back(c);
        else v.push_back(c);
    }

    for (auto x : m) std::cout << "key=" << x.first << " value=" << x.second << std::endl;
    
    system("pause");

    return 0;
}