Question: what is are command for c program to run in shell
Repl link:
code snippet
Question: what is are command for c program to run in shell
Repl link:
code snippet
Welcome to the community, @shivakumar0343!
To run a C program in the shell, you can type ./main
in the shell.
i have tried but it is printing the main.c answer i want to print answer for new file which i have created
Hi @shivakumar0343 , welcome to the forums!
Unfortunately, you can only have 1 C file made at a time, as 2 files will cause an error. You’ll have to move the code into main.c
.
Hope this helps!
(Configuring the .replit
file gives errors, so don’t try that)
Hey @shivakumar0343, you can only have one C file in the Repl. Like @NateDhaliwal said, you can move your code into the main.c
file.
Actually, C will look for any C file, not just the main.c
file.
Hey @shivakumar0343 !
Is your question answered? Has your problem been silved?
If it has, you can mark the post that helped you most as a Solution?
If not, do you have any further questions?
hey there, you need to firstly compile your code like so:
make -s # quick shortcut for compiling using pre-made `make` config file
./main # essentially, you create a bytecode file of the same name as your file so you can just do `./file_name`
please note that the premade config file is visible by pressing show hidden files
and that it’s configured on default to compile main
so if you want to compile another file please edit it to look like this
all: $`{FILE_NAME}`
CC = clang
override CFLAGS += -g -Wno-everything -pthread -lm
SRCS = $(shell find . -name '.ccls-cache' -type d -prune -o -type f -name '*.c' -print)
HEADERS = $(shell find . -name '.ccls-cache' -type d -prune -o -type f -name '*.h' -print)
main: $(SRCS) $(HEADERS)
$(CC) $(CFLAGS) $(SRCS) -o "$@"
main-debug: $(SRCS) $(HEADERS)
$(CC) $(CFLAGS) -O0 $(SRCS) -o "$@"
clean:
rm -f main main-debug