I wrote a function in a DLL that accepts a structure of vectors as an argument which is passed by reference and modifies the argument's data.
I export that function using a .def file to be used by another EXE and processes the data in the Structure of vectors.
Below i the Sample Code for that implementation:
Struct data // Defined in both DLL and EXE
{
vector<int> IsEnabled;
vector<string> Path;
};
IN DLL:
void func(data& ret)
{
data temp;
temp.IsEnabled.push_back(1); temp.Path.puch_back("C:\\Program Files\\");
ret = temp;
}
IN EXE:
int main()
{
if(true)
{
data a;
func(a);
for(int i = 0; i<a.IsEnabled.size(); i++)
{
cout<<a.IsEnabled[i]<<"\t:"<<a.Path[i]<<endl;
}
} // End of 'if' condition
}
This program is crashing when it reaches the end of the 'if' condition. I found out the reason for this. But is there any modification that I can make to my code or any other way by which i can achieve what i am trying to do here?