I need to include file_1.c into main.c. In file_1.c, I currently have multiple functions. If I want to call these functions in main.c, what do I need to do? I have #include”file_1.c” in my main program.
I need to include file_1.c into main.c. In file_1.c, I currently have multiple functions.
Share
Use standard approach by making header file
#include"file_1.h"you will have to compile this
"file_1.c"together withmain.cand make one executablebecause function calls are need in run time.
Try this :
create a header file
file_1.hgive all the declaraion of function and struct definitions (if any) or any global variables
then in
file_1.cwill contain actual defintion of functioninclude header file
file_1.hin both (main.candfile_1.c) thecfilesIn
gccgcc -Wall main.c file_1.c -o myexe.out