mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-30 14:07:50 +00:00
aa3eac143d
* lisp/ob-C.el (org-babel-C-execute): Remove the erroneous call to `org-babel-read' when output is raw. * testing/examples/ob-C-test.org (Output), testing/lisp/test-ob-C.el (ob-C/ouput-doublequotes): Add a test with double quotes output. https://list.orgmode.org/orgmode/bc004962-679e-498f-b245-ae253aae6271@www.fastmail.com/
3.9 KiB
3.9 KiB
a collection of examples for ob-C tests
Simple tests
std::cout << 42;
return 0;
std::cout << 42;
return 0;
writefln ("%s", 42);
std::cout << q;
return 0;
writefln ("%s", q);
std::cout << p+q;
return 0;
writefln ("%s", p+q);
std::cout << q << ' ' << std::strlen(q);
return 0;
writefln ("%s %s", q, q.length);
std::cout << N;
return 0;
Array
for (int i=1; i<3; i++) {
std::cout << i << '\n';
}
return 0;
foreach (i; 1..3)
writefln ("%s", i);
Matrix
1 | 2 |
3 | 4 |
std::cout << a[0] << a[1] << sizeof(a)/sizeof(*a) << '\n';
writefln ("%s%s%s", a[0], a[1], a.length);
std::cout << a[0] << a[1] << sizeof(a)/sizeof(*a) << '\n';
writefln ("%s%s%s", a[0], a[1], a.length);
std::cout << q[0][0] << ' ' << q[1][0] << '\n'
<< q[0][1] << ' ' << q[1][1] << '\n'; // transpose
writefln ("%s %s", q[0][0], q[1][0]);
writefln ("%s %s", q[0][1], q[1][1]); // transpose
Inhomogeneous table
day | quty |
---|---|
monday | 34 |
tuesday | 41 |
wednesday | 56 |
thursday | 17 |
friday | 12 |
saturday | 7 |
sunday | 4 |
int main()
{
int i, j;
for (i=0; i<tinomogen_rows; i++) {
for (j=0; j<tinomogen_cols; j++)
printf ("%s ", tinomogen[i][j]);
printf ("\n");
}
printf ("Friday %s\n", tinomogen_h(4,"day"));
return 0;
}
import std.stdio;
void main()
{
for (int i=0; i<tinomogen_rows; i++) {
for (int j=0; j<tinomogen_cols; j++)
writef ("%s ", tinomogen[i][j]);
writeln();
}
writefln ("Friday %s", tinomogen_h(4,"day"));
}
Output
std::cout << "\"line 1\"\n";
std::cout << "\"line 2\"\n";
std::cout << "\"line 3\"\n";