PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Compiling C With Linux

Go down

Compiling C With Linux Empty Compiling C With Linux

Post by jamied_uk 15th July 2016, 14:56

Compiling C With Linux



Use Geedit and create a file called hello.c


Code:
#include <stdio.h>
main() {
printf("Hello World
\
n");
}


Code:
gcc -o hello hello.c



execute file

./hello


Test file

file hello

strings hello|grep -i -A 10 hello

cat hello

strings hello|grep -i -A 10 world

strings f|grep -i -A 10 hello


You can even put the compile line into a bash script

Code:
#!/bin/bash
gcc -o hello hello.c
jamied_uk
jamied_uk
Admin

Posts : 2942
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Compiling C With Linux Empty Re: Compiling C With Linux

Post by jamied_uk 17th July 2016, 12:04

Creating a function in .bashrc to make this so much easier and faster!


Code:

# put this in your .bashrc file
# Usage compile file.c
#
function compile() {
myvar="$@"
gcc -o file.exe "$myvar"
sudo chmod +x file.exe
echo "All Done!"
}
jamied_uk
jamied_uk
Admin

Posts : 2942
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum