How would I reuse functions in C? I've tried simply sticking them in a #include <myfunctions.h>
, but that didn't work... Any (complete) suggestions/links on how to do this? I googled some and found this:
The way to write a header file is:
functions.h:
int sum( int a, int b) ;
functions.cpp:
#include "functions.h"
int sum( int a, int b) {
return a+b ;
}
compile:
g++ -c functions.cpp -o functions.o
main.cpp:
#include "functions.h"
main() {
cout << sum(1,2) << endl ;
}
compile and execute main:
g++ main.cpp functions.o -o main
main
How would I, obviously replacing g++ with gcc and *.cpp with *.c, do these steps in Code::Blocks?
Thanks in advance,