The issue that I am having is that I am trying to build a DLL. And I am using char instead of strings to store information.
I have defined the following in the header file:
class Test{
public:
int qLenght;
char firstName[];
char surName[];
};
I am having problems inputting codes from the main program using the following:
int main()
{
Test theTest;
theTest.firstName[0] = {"Mike Smith","Jonny Vegas","Jimmy Woo"};
}
I have included the header code at the top of my main project.
It won’t let me add to the char array. This may seem like a stupid question but I am struggling and hopefully someone can shed some light as to where I am going wrong. Am I missing a parameter?
Your class needs to know how much memory to allocate when you instantiate the class (which is not the same time as you assign the values).
Alternatively, you can allocate memory for the strings dynamically at the time of assignment, but then you need to remember to free it again: