I'm still a bit new at making programs... Could someone explain to me exactly how to put functions in separate files from the one containing main()? Thanks.
I'm still a bit new at making programs... Could someone explain to me exactly how to put functions in separate files from the one containing main()? Thanks.
The actual mechanics of it can vary from compiler to compiler. I work primarily on Linux, using gcc and make, but I know there are IDEs on Windows that let you drag/drop files into project folders etc.Originally Posted by Lord Xela
Basically though, what you're looking to do is have a file, say a.c, that has your main function. In that file, you will include b.h -- b.h contains the function declarations for your other source file (call it b.c) that contains your function code.
Now, you want to build all that together. You basically compile b.c into an object file (b.o) and then make sure that you link that object file in when you compile and link a.c
It is hard to describe that last part without getting compiler specific
Hope that's a help....
(If not, at least it is a starting point for others to work off of.....)
Mr. Blonde: You ever listen to K-Billy's "Super Sounds of the Seventies" weekend? It's my personal favorite.
Hi,
'fgw' is very right about the concept. that is the proper way of doing things.
But as u r a beginner. u can use one thing also. write functions in different files. like a.c, b.c and c.c are three different files containing two- two functions in each.
now Main.c is ur main file. include these a.c, b.c and c.c file in Main.c with proper path. and use those function in main().
I dont know what does C standard say about this, but it will work.Code:#include "path/a.c" #include "path/b.c" #include "path/c.c"
S_ccess is waiting for u. Go Ahead, put u there.