I can not find how to run a c program in the emacs terminal. I can compile it with M-x cc filename.c and it works fine. What is the command to run the program. M-x (what do i type).
To compile a program in Emacs, type Escape followed by x followed by compile, or use the pull down "tool" menu and select compile.
Executing External Commands You can execute an external shell command from within Emacs using ` M-! ' ( 'shell-command' ). The output from the shell command is displayed in the minibuffer or in a separate buffer, depending on the output size.
If the script is executable, you can execute it with C-c C-x ( executable-interpret ). You'll be given the opportunity to pass arguments. (This command works no matter what language the program is written in, by the way, as long as the file you're editing is executable.)
A much better idea would be to use a Makefile
---- X Makefile X----
build:
gcc -o exec_name input.c
run:
./exec_name
And then you can do M-x compile and give command as make build to compile the program and M-x compile followed by make run to run the program.
Another way of running would be M-x gdb
shell-command
is what you're after.
Ask Emacs about it: C-h f "shell-command". It's bound to M-!
EDIT: clarify exact action required
Do this:
M-! foo-program enter
Where foo-program is the name of the compiled executable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With