William Everett
William Everett

Reputation: 781

Why does this org-babel c snippet produce no output?

Basically, printf doesn't produce output if I put it in main().

This works:

#+begin_src C
printf("Hello World!\n");
#+end_src

But this

#+begin_src C
void main() {
printf("Hello World!\n");
}
#+end_src

results in

Code block produced no output

I have tried adding :results output to the begin_src line. I have tried including stdio.h. When I look in *Messages*, I see that when I wrap the printf in main, I get the error

**Error reading results: (beginning-of-buffer)**

What is wrong here?

Upvotes: 1

Views: 348

Answers (1)

kikiz
kikiz

Reputation: 40

Try this:

#+name: main
#+begin_src C
int main(int argc, char *argv[]) {
printf("Hello World!\n");

return 0;
}
#+end_src

Upvotes: 2

Related Questions