Run a C program?

How do I run another C program from the console? I have tried researching and cannot find anything.

1 Like

You need to compile it.
then you can run it in a shell. Just make sure you use ./ in front of the name


Okay, I compiled it. But then what is the command to execute it within the shell? When I last looked, it compiles into .exe. Is this able to run in the shell at the file format?

You can run the executable but since probably the path is nit set put ./ in front of the name.

@fpessolano Very well. I am asking this for a C projects named B-OS that I am working on:

Open a shell (not console) and type ./main hit return and it should work. The executable is called main but you need the path to is that is ./, hence ./main

I reproduced this error. Can you explain this?
Screen Shot 2023-03-04 at 9.49.01 AM

Well you have an error, so it did not compile. I would need to delve into your code but I am on an iPad flying over Boston and is kind of difficult to debug code like this,

I thought airplane mode was a thing. laughs

The only issue seems to be that the setup_main function is missing a main function to call it.

You can buy internet these days but I would need a laptop to see the code well.
Is there a main func in the setup.c? Is setup.c your am or main.c?

setup.c is an arbitrary program I created for the main user home file. My main.c file is the main one, and runs the prompt engine. Primarily, my objective is to have the user use a custom made command such as rn setup or rn setup.c to run a specific program within that directory. When the program finishes, the prompt returns to the main.c prompt. The problem is that I can’t have two int mains. But then when I compile, it says it is missing.

That is a different problem than the original one. I suggest you post it with details again as a new post and it will attract lot of attention from the few c users here.

1 Like

run this in shell:

make -s; ./main
1 Like

I did, it worked. But I would like to run “make -s; home.u/user/setup.c”. So, yes, you have solved my problem, but now it says permission denied. How do I fix this.
Screen Shot 2023-03-04 at 11.04.28 AM

1 Like

Run this:

make -s # compile all directories recursively iirc
chmod u+x ./home.u/user/setup.c # make setup.c executable
                                # (changes the perms of the user for this file)
./home.u/user/setup.c # run it

I want it to be able to run without compiling and turning it into an EXE. This problem is a permission problem. I need to give the system permission to the folder. I am pretty sure that there is a command for that.

1 Like

yeah… that’s it chmod changes the perms of a file so that you can read/write to it

1 Like

So then would I command chmod home.u/user?

1 Like

No, you would run:

make -s # compile all directories recursively iirc
# changes the permissions so you can access the compiled ver
# important that you add `u+x` because that means you can actually read/write
chmod u+x ./home.u/user/setup.c
./home.u/user/setup.c # run it