G
Guest
I am manually building a DataTable in a function and trying to pass it back
to a DataTable pointer. When I pass it back as a return value, the pointer
is populated correctly and I can access the rows. If I pass the pointer as
an argument of a function it doesn't keep the data after the function is
completed.
This works...
DataTable *buildTable() {//build table};
main()
{
DataTable * myTable;
myTable = buildTable();
//myTable is populated by buildTable function
}
This doesn't...
void buildTable(DataTable *DT){//build table and assign to DT};
main()
{
DataTable *myTable;
buildTable(myTable);
//myTable still shows uninitialized
}
I don't always know what the table structure is going to be and I need the
second way to work because I will need the return value for a different use.
to a DataTable pointer. When I pass it back as a return value, the pointer
is populated correctly and I can access the rows. If I pass the pointer as
an argument of a function it doesn't keep the data after the function is
completed.
This works...
DataTable *buildTable() {//build table};
main()
{
DataTable * myTable;
myTable = buildTable();
//myTable is populated by buildTable function
}
This doesn't...
void buildTable(DataTable *DT){//build table and assign to DT};
main()
{
DataTable *myTable;
buildTable(myTable);
//myTable still shows uninitialized
}
I don't always know what the table structure is going to be and I need the
second way to work because I will need the return value for a different use.