/Basics

Basics of C, C++

Primary LanguageC

Basics

C, C++

GCC stands for GNU compiler collection.


gcc file.c -o file #compile c file and link it

./file #execute the c code

===

g++ file.cpp -o file #compile c++ file and link it

[if there are several cpp files, then g++ file1.cpp file2.cpp -o file]

./file #execute the c++ code


g++ -c file.cpp #compile cpp without building, this will generate object file file.o

g++ file.o -o file #make object file executable

./file #execute the c++ file

makefile

cd myproject

make #compile all binary

make clean #remove all binaries andobjects

make target_name

Bash

cd ..

touch myscript.sh #create a bash file

chmod +x myscript.sh #make the bash file executable

./myscript.sh #execture the bash file