Pass org-mode table data into org-mode C++ source code block -
how access org-mode table data in c++?
#+tblname: prob-calc | | 353.02 | | b | 398.00 | | c | 241.0 | | d | 1 | #+begin_src c++ :var tbl=prob-calc :includes <stdio.h> :results output // in other languages, python, can evaluate tbl // see values (and of course access them in usual python // way. same r, common lisp. possible c++? // suspicion can't done in c++. // goes here it? #+end_src
thanks in advance
this seems work:
#+tblname: prob-calc | | 353.02 | | b | 398.00 | | c | 241.0 | | d | 1 | #+begin_src c++ :var tbl=prob-calc :includes <iostream> <cstdlib> :results output int row, col; (row=0; row < tbl_rows; row++) { (col=0; col < tbl_cols; col++) { std::cout << tbl[row][col] << " "; } std::cout << "\n"; } #+end_src #+results: : 353.02 : b 398.0 : c 241.0 : d 1
on linux, source file written in /tmp/babel-<mumble>/c-src-<mumble>.cpp
, , table declaration in file looks this:
const char* tbl[4][2] = { {"a","353.02"}, {"b","398.0"}, {"c","241.0"}, {"d","1"} }; const int tbl_rows = 4; const int tbl_cols = 2;
Comments
Post a Comment