ankursethi
June 22nd, 2008, 08:32 AM
I'd posted a question here a few days ago asking what I should do next after having learned basic C and Python. I've followed the advice most people gave me and picked up a good data structures book.
Now my programs are getting larger and managing huge source files is getting tough. I need to know how to use multiple files. After poking around for a while and looking at other people's code, I found these two methods :
1. #include all the *.c files in the file containing the main function.
2. Create header files containing function and global declarations for all the *.c files. Create object files for each C source file. Then #include the header files in the file containing main, compile it and link it with the object files.
Which method should I follow? Or is there any other procedure for managing multiple files?
Now my programs are getting larger and managing huge source files is getting tough. I need to know how to use multiple files. After poking around for a while and looking at other people's code, I found these two methods :
1. #include all the *.c files in the file containing the main function.
2. Create header files containing function and global declarations for all the *.c files. Create object files for each C source file. Then #include the header files in the file containing main, compile it and link it with the object files.
Which method should I follow? Or is there any other procedure for managing multiple files?