Ok, sorry to be so long in responding, I have limited access to the boards from work...
Anyway, here is the code (sorry it's not in a compilable format):
1 2 3 4 5 6 7
|
class Test {
public:
char Name[8];
int ID;
int TestID;
Test();
}
|
then, in my main program, I am reading in a file entry that has, for legacy and formatting reasons, be read in one character at a time...
1 2 3 4
|
while (ch != '\n' || counter == 10) {
tmpCharBuff[counter] = fgetc(lookupFile);
counter++;
}
|
memcpy (&tmpCharBuff[counter], "\0", 1);
Once checks have been made that this is formatted correctly for the later output that will be required (all of this stuff works), I need to now "stuff" this into the object defined above, namely the Name field of the Test class.
If this were a single object, I could just set it equal to it, but since the above Test class has an unknown amount of instances contained in a vector called MyTest, defined like this:
vector <Test> myTest;
I am not sure how to proceed. Legacy code has similar operations that do not go into a vector object, but a single struct. So I was trying to use something like this:
memcpy(&myTest[chcount].Name, tempBuff, sizeof(tmpBuff));
Which fails miserably (Causing a catastrophic error in the execution, which results in a "This application has encountered an error and has to close."), since this instance of Test has not been initialized. But trying to initialize it how? That is really my question here.
I am sure I am missing something blatantly obvious...
Thanks for all your feedback so far, just bear with me, please, if I take a little longer in responding.