c++ export array of struct

Discussion in 'HelpDesk' started by PseudoCoder, Oct 11, 2018.

Tags:
  1. Ps

    PseudoCoder DEV Guild Member DEV Guild

    Joined:
    Sep 5, 2008
    Messages:
    112
    Likes Received:
    1,937
    Hello i'v the following function that exports a single instance of a struct :
    Code:
    struct UserIdentity
    {
    std::string name;
    int id;
    };
    
    std::map<std::string, int> g_UserIdentities = { { "Bob", 100 }, { "Jone", 101 },
                { "Alice", 102 }, { "Doe", 103 } };
             
    /*
    * Will be used in a DLL that will export UserIdentity struct
    * OUT _UserIdentity
    */
    
    void Ui_export(UserIdentity *_UserIdentity)
    {
    for (auto& t : g_UserIdentities)
        {
         _UserIdentity->name = t.first;
         _UserIdentity->id   = t.second;
        }
         
    } 
    So please how could i export an array of _UserIdentity instead of a single instance in my function
    Code:
    void Ui_export(UserIdentity *_UserIdentity)
    thank you .
     
    Last edited: Oct 11, 2018
  2. Ps

    PseudoCoder DEV Guild Member DEV Guild

    Joined:
    Sep 5, 2008
    Messages:
    112
    Likes Received:
    1,937
    Thank you all , GOT IT .