Hello I am learning c and I have created a simple script. I ran it with gcc simplify.c -o simplify
.
Here is the c script
#include<stdio.h>
int main(){
int age = 3;
printf("%i\n", age);
return 0;
}
when I try to run it
$simplify.exe
bash: run: command not found
I get the result shown. What am I doing wrong
CodePudding user response:
Whenever you use a filename as a command, bash will search for it in directorys like /usr/bin
. Imagine the situation, in which someone put a executable called ls
somewhere unprotected on your computer. Like @some programmer dude pointed out, you habe to explicitly specify the path to your executable. This path can be relative (./simplify.exe) or absolute (/home/username/projects/simplify/simplify.exe).
By the way, on linux systems it is umcommon to use a file ending, espacially ".exe". If you want to use one, I recommend ".elf", which stands for "executable linkable file". (You can do so much more than EXEcuting a file - and down we go the rabbit hole)