Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permission denied when running C program [closed]

Tags:

c

I am trying to run this basic file (ex1.c) with zsh

#include <stdio.h>
int main(int argc, char *argv[])
{
    puts("hello world.");

    return 0;
}

I am getting this error:

zsh: permission denied: ./ex1.c
like image 249
eden Avatar asked Aug 26 '13 14:08

eden


1 Answers

You need to compile it first, probably by doing gcc -o ex1 ex1.c.
After compiling it, you will have an executable called ex1, which you can run by doing ./ex1. If you receive another permission denied error, you can make it executable by doing chmod +x ex1.

like image 130
Matt Bryant Avatar answered Oct 04 '22 00:10

Matt Bryant