You have to give it exe. permissions.
So: chmod +x new_file
When you create a new file with your gcc, by default, this isn't executable. So, you have to gave it permissions of execution.
With chmod (see this) you change permissions on file.
In that specific case, you gave execution permissions ( + [plus] means gave, 'x' means execution ) to that file.
If you want to revoke that permission, you can type: chmod -x filename
I've been wanting to switch my computer to Linux, just to get better with computers, and to see what I can customize. The problem is, that I don't know where to start. A lot of vocabulary gets thrown around (servers, distros, etc.), and I end up in a rabbit hole where I don't understand anything. Is there any online courses that start at a very beginner level, that help teach C programming, and that focus on using/switching to Linux?
Executing C program in Linux Terminal - Stack Overflow
python - What does "-c" mean in this linux shell command? - Stack Overflow
In the Linux Kernel, how are callbacks and trampolines designed and implemented : C_Programming
Linux From Scratch to learn C and Linux?
No, not really. LFS is a manual to assemble your only Linux system. As far as I know, it doesn't actually teach you a lot about how the components work, it's just a list of steps to follow.
Perhaps read learn C the hard way or just The C Programming Language and then see how far this brings you. I can also not stress enough the importance of reading other people's code to learn how to write good C code.
More on reddit.comVideos
You have to give it exe. permissions.
So: chmod +x new_file
When you create a new file with your gcc, by default, this isn't executable. So, you have to gave it permissions of execution.
With chmod (see this) you change permissions on file.
In that specific case, you gave execution permissions ( + [plus] means gave, 'x' means execution ) to that file.
If you want to revoke that permission, you can type: chmod -x filename
After compiling, the file is placed in a.out
Try to use a.out.
You need to compile your program before you can run it. To do this, you'll need a C compiler, like gcc. You can install this with:
sudo apt-get install gcc
Then, to compile your program, creating an executable called file:
gcc -Wall -o file file.c
Which you should then be able to run:
./file
Fabrice Bellard's TCC seems to be still in the repositories. It can run in a kind of interpreter-mode which makes the following possible:
You can make a simple C-file executable like the OP tried to do by adding the line
#!/usr/bin/tcc -run
to the very top of the file.
It also accepts input from STDIN by adding an empty option (just the minus sign -) at the end.
$ /usr/bin/tcc -run - <<EOF
> #include <stdio.h>
> int main()
> {
> printf("Hello World\n");
> return 0;
> }
> EOF
Hello World
or with echo
echo '#include <stdio.h> int main(){printf("Hello World\n");return 0;}' | /usr/bin/tcc -run -
or just run /usr/bin/tcc -run - type your code and start the run with CTRL + D
Seems useless and silly but the last method is the fastest (for me, YMMV etc.) to check for a function in a large library, look up the exact value of a constant etc. And it is small (180k) which makes it a good fit for e.g. the Raspberry-Pi.
Main disadvantage: development stopped (last version is from 2013).
-c stand for cmd which allows you to pass your code as a string. This feature is available even outside of google-cloud-platform. you can check other available options using python -h
the -c flag means execute the following command as interpreted by this program.
Doc: https://askubuntu.com/questions/831847/what-is-the-sh-c-command