Compiling C With Linux

View previous topic View next topic Go down

Compiling C With Linux

Post by jamied_uk on 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
avatar
jamied_uk
Admin

Posts : 2278
Join date : 2010-05-09
Age : 34
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Compiling C With Linux

Post by jamied_uk on 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!"
}
avatar
jamied_uk
Admin

Posts : 2278
Join date : 2010-05-09
Age : 34
Location : UK

http://address-shortner.co.uk

Back to top Go down

View previous topic View next topic Back to top


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