Hello,
My C++ code is rusty. I haven't used it for quite some time. As a result, certain structures and how to access them have been at least temporarily forgotten. I have the following array, that I want to search in order to find the corresponding Table (SQL) name. It's not quite working out the way I wish. It doesn't seem to be indexing by element, but rather by character.
filedata defined as:
Code:
const char filedata [][20] = {
"fileId\0",
"fileid\0",
"filename\0",
"filename\0",
"filesize\0",
"filesize\0",
"fileurl\0",
"fileURL\0",
"filetitle\0",
"title\0",
"filecontent\0",
"content\0",
"Description\0",
"description\0",
"fileimage\0",
"imageURL\0",
"fileimagestyle\0",
"imagestyle\0",
0
};
Keytable is declared in class Sysinfo:
Code:
class Sysinfo
{
private:
public:
ifstream InFile;
...
char *Key;
long KeySz;
char *Value;
long ValueSz;
char *KeyTable;
...
};
The following code does not work as desired
Code:
KeyTable = (char *)&filedata;
Index = 0;
while(KeyTable[Index])
{
if(!(strcmp(&KeyTable[Index], Key)))
{
IsFileDataItem = True;
CurrentFileTabIndex = Index;
break;
}
Index += 1;
}
The results are:
Pass 1
Code:
Index: 0
&KeyTable[Index]: "fileId"
The 1st pass pointing to proper place
Pass2
Code:
Index: 1
&KeyTable[Index]: "ileId"
The 2nd pass not pointing to proper place
what is wanted in Pass 2 is the 2nd element of the string array 'fileid' (Internal name vs SQL table .schema name)
There is an obvious disconnection between the declaration of the constant array and my 'Address of Array element'. What am I doing wrong?
Lar