reddit / emacs

How can I get source block in org mode to work with scanf() ?

pla9ue · 2022-04-20 19:17
so basically, My CS assignment is on due tomorrow and i have written everything in org mode. But the problem is , C-c C-c does not work well with scanf() or any function that relies on stdin. I am very bad at emacs lisp so i can't hack emacs right now. Is there a way to execute the compiled binary in eshell and copy back the result in the Result block ? If you guys have a solution, please help edit so , i just started using this stupid bash script &#x200B; `#!/bin/bash` `echo $(xclip -selection c -o) > prog.c` `cat res prog.c > temp` `cat temp > prog.c` `gcc -o test prog.c` `echo "#+BEGIN_SRC"` `./test` `echo "#+END_SRC"` `rm test` `rm temp` where `res` is &#x200B; `#include <stdio.h>` `#include <stdlib.h>` `#include <string.h>` &#x200B;
ieure · 2022-04-20 21:41
Org-babel isn't intended for running programs that take input from the user, so that's not supported. You can put your input in another Org source block and use noweb to stick it in a `const char*` in your C block.
dm_g · 2022-04-21 03:56
shell supports one header parameter called stdin that use another block as is input \#+name: myinput \#+begin\_src sh echo "Hello world" \#+end\_src \#+RESULTS: myinput \#+begin\_example Hello world \#+end\_example \#+begin\_src sh :stdin myinput cat \#+end\_src \#+RESULTS: \#+begin\_example Hello world \#+end\_example unfortunately this header parameter is not supported by C. Only by shell, awk and sed. i think this would be a good addition to all languages.
xenodium · 2022-04-21 05:42
Seen this? https://www.reddit.com/r/emacs/comments/or2p4z/can_i_get_an_org_mode_python_code_block_to_ask