0

I'm new in linux trying to run .C program from another directory in script. script is in home directory and .C program is in Desktop directory. here is script.

#!/bin/bash
chmod 777 myscript
cd /home/unifi-007/Desktop/
gcc main -o main.c
./main

But i'm not getting it right. how to execute main.c in script.

1 Answer 1

1

The usage of gcc is clearly wrong, it should be gcc -o main main.c.

BTW, .C is a suffix for C++ (at least for GCC it is), not C.

BTW again, normally, you do not run a C source file, you compile it, and run the executable file generated by compiler (by linker, actually).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.