Hi,
I've run into thi sproblem a few times in my program. I have a number of arrays in a class, and I fill them in order one by one. But once I write to a praticular array the contents get copied at the end of another array. here's a snipet of my code:
Class deffinition:
Code:
class gVars
{
public:
std::vector < CString > vectBP;
std::vector <CString> vectParmSelected;
char hEngName[13];
char hVersion[13];
char EngName[11];
int VersionNum;
gVars()
{
VersionNum=0;
memset(hEngName, 0, sizeof(hEngName));
memset(hVersion, 0, sizeof(hVersion));
memset(EngName, 0, sizeof(EngName));
};
};
the main to fill the arrays:
Code:
.......................................
FindWord(inp,"!EICAS_SW_VER", vars.hVersion);
fprintf(out, ">%s<\n\n", vars.hVersion);
SkipWS(inp);
GetWord(inp,Word);
vars.VersionNum=atoi(Word);
fprintf(out, ">%s<\n\n", vars.hVersion);
FindWord(inp,"!ENGINE_NAME", vars.hEngName);
SkipWS(inp);
fprintf(out, ">%s<\n\n", vars.hVersion);
GetWord(inp,Word);
fprintf(out, ">%s<\n\n", vars.hVersion);
strcpy(vars.EngName, Word);
fprintf(out, ">%s<\n\n", vars.hVersion);
.........................
the output:
Code:
>!EICAS_SW_VER<
>!EICAS_SW_VER<
>!EICAS_SW_VER<
>!EICAS_SW_VER<
>!EICAS_SW_VER"Engversion"<
All the strings should be identical.