Thread: How do you call another source code file?

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    18

    How do you call another source code file?

    So I finished the first part of my program... but he called and he wanted me to split it up into different sections of the program. Like into another source code. How do I call another source code thats in a different source code file, but yet in the same source folder?

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    That sounds like more a matter of convention than anything else. Anyway, I recommend compiling libarary files (.a or .lib files) and using headers to define the functions in the archives.

  3. #3
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    You don't "call" another source file. You can split your single source file into multiple source files and have individual functions in one of those files call other functions in other source files. All you'd need to figure out is how to compile/link the source/object files (this is usually done in modern IDEs by creating a project and adding all the source files to the project) and also make sure that functions in one source file that need to call the functions in other source files know about the names and return types and arguments of those other functions (and that's done with headers and function prototypes).
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Source file inclusion
    By sh3rpa in forum C++ Programming
    Replies: 7
    Last Post: 10-02-2007, 11:10 AM
  2. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  3. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  4. VS 7.1 Linux Source code solution / project file?
    By cboard_member in forum Tech Board
    Replies: 6
    Last Post: 07-30-2006, 02:07 PM