hello all..i have problem with my program wroten in Borland C++ Builder witch contains structure and grafics as forms and tables... when i trying to write to structure from table cells or function made by myself, compiler aller me with error as Lvalue required and a really dont know where the problem can be..
}
a_database;
extern a_database *my_database[100];
extern int index=0,i;
//-----------------------------------------
void add (ShortString _name,ShortString _surrname,ShortString _type,int _count)
{
my_database[count]=(a_database*) malloc(sizeof(a_database)); (*my_databaza[index]).name = _name;
(*my_databaza[index]).surrname = _surrname;
(*my_databaza[index]).type = _type;
(*my_databaza[index]).count = _count;
index++;
}
compiler shows me error on underlined parts, where i can write into struct..
//---------------------------------------------------------------------
and my second problem..
function to write contents of structure into table.. but compiler shows me error: "cannot convert Shortstring to Ansistring" on underlined parts... and i dont now what i could do..
void show (int xindex)
{
for (i=0;i<xindex;i++)
{
Database->Table->Cells[0][i+1]=i; Database->Table->Cells[1][i+1]=(*my_database[index]).name;
Database->Table->Cells[2][i+1]=my_database[i]->surrname;
Database->Table->Cells[4][i+1]=my_database[i]->type;
Database->Table->Cells[6][i+1]=my_database[i]->count;
}
Databaza->Tabulka->RowCount = xindex+1;
}
can anybody help?? i am helpless.. thanks.. and i am sorry for my english..
please use the code tags when printing code. Makes it infinitely easier to read. Also don't underline code that has underscores.
Your first problem: my_databaza is not declared anywhere that I can see. But assuming that's not the problem, and it's of type a_database*, you don't use * and [] to dereference the pointer. It's one or the other. foo[0] is the same as *foo and foo[index] is the same as *(foo+index). Using both * and [] only makes sense if you have a double pointer (ie: a_database**)
Your second problem is the same. Only use -> with a pointer. Once you use [], you no longer have a pointer. foo[0].whatever() or foo->whatever or (*foo).whatever. Pick one. Don't mix and match.
Also -- if this is C++, ditch the ridiculous C struct typedef crap (it also might help to employ other C++ practices like classes/container types/etc)