0

This is my first time using Ubuntu to run a C-File with a codeBlocks

  1. I tried save as a File "file1" without extension file.

    Permission Denied

  2. I tried chmod u+x file1

    Wrong something but builded success

  3. I tried give "file1.c"

    File not found

Snake Eyes
  • 430
  • 3
  • 18
BeGood
  • 539
  • 1
  • 6
  • 18

2 Answers2

0

First of all, Any C program is saved with .c Extension. And C++ program is saved with .cpp extension.

Now coming to compilation,

  1. If you want to compile it using Terminal, Open the terminal (Press CTRL + ALT + T).

  2. Go to the directory where the file is saved. (You can use cd command to change directory).

  3. After reaching the directory , type gcc file1.c.

  4. If there are no errors, then you can run the output by typing ./a.out.

Snake Eyes
  • 430
  • 3
  • 18
-1

Make sure you're the owner of the files. If you're not, you can run:

sudo chown usrname:username /path/to/your/file

Also make sure it's executable:

chmod +x /path/to/your/file
Bilal
  • 3,629
  • 2
  • 25
  • 35
  • Users generally own the files they create automatically, and compilers automatically set execute permissions on the executable binaries they create (unless they can't, for example due to the filesystem not supporting it, in which case manually running `chmod +x` will also fail). A compiler might not make the program executable for the user [if umask is set unusually](https://askubuntu.com/a/44752/22949), but then [a different `chmod` command would be needed as well](https://askubuntu.com/a/932719/22949). – Eliah Kagan Jul 30 '17 at 17:48