Getting table data into C++ variables

Hi,

I am new to kdb. I got below code, which doesn’t work - could you
please let me know where I am going wrong?.
cout doesn’t print anything - it breaks in assigning columnNames.

int c = khpu(“localhost”, 9090 ,“id:pwd”);
K mytab, columnNames, columnData;

result = k(c,“d:namesalary! (tomdick`harry;30 30 35)”,(K)0);

int nCols,nRows;

mytab=ktd(result);

columnNames=kK(mytab->k)[0];
columnData=kK(mytab->k)[1];
nCols=columnNames->n;
nRows=columnData->n;

cout << "Columns are : " << nCols << "Rows are : " << nRows << endl;

Thank you.

original example csv.c does work - but not when assign formatted table
like below.

Please can somebody help.

Thanks.

you are creating a dictionary, not a table.

if you flip your object it should work

e.g.

flipnamesalary! (tomdick`harry;30 30 35)

or if you do want to work with a dict, don’t call ktd.

ktd is just for removing a key on a table making it easier to pick apart.

Thanks a lot Charles. It worked.