I've defined in my foo.h
the following variables
#define APILONG long
#define APIDOUBLE double
#define APISTRING const char*
And also the following struct
struct SetupData
{
APISTRING customerName;
APIDOUBLE quantity;
APILONG startDate;
};
Now, in my foo.cpp
i have the following method where I need to assign values to the members of the struct that are being pulled from a .config
file.
APILONG doSomething(APISTRING* setupOrder, APILONG* setupActive, struct SetupData** setupData)
{
//load config file
Config config("rommel.config");
//assign a string value to APISTRING* (No issue here.)
*setupOrder= config.pString("setupOrder").c_str();
//assign a value (No issue here, atleast not that I know of..)
*setupActive = config.pDouble("setupActive");
//assign values to members of struct**
(*setupData)->customerName = config.pString("setupDataCustomerName").c_str();
(*setupData)->quantity = config.pDouble("setupDataQuantity");
(*setupData)->startDate = config.pDouble("setupDataStartDate");
//do other stuff..
}
When I compile and rebuild it does not give me any error messages. But when I try to run the actual program it crashes. (Am using Dev-C++, Visual Studio was causing problems..) I do however get a chance to see the values assigned before it crashes and it looks like the values are not being assigned (Null or strange characters).
I've tried variations of the
(*setupData)->startDate ..
line and also I have tried declaring the struct in the method like the following, but to no avail.
struct SetupData stpData;
*setupData = &stpData;
Any help would be greatly appreciated. I previously posted another question which is related to this, it contains some pretty useful information aswell. I'll leave the link in case it helps. "C++ Set value for a char**"