Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How can I insert another program in my program in C.

  1. Apr 28, 2015 #1
    I have to insert my friend coding in mine and I don't know how to do it can someone help me.
     
  2. jcsd
  3. Apr 28, 2015 #2

    DrClaude

    User Avatar

    Staff: Mentor

    1. Compile the different parts as object files and link them together.
    2. #include
    3. Cut and paste
     
  4. Apr 28, 2015 #3

    jedishrfu

    Staff: Mentor

    To be clear DrClaude's suggestions are choices and not steps.

    1 You can create a library of your friends code and then call his functions in your code. You may also need to create an include file of your friends function definitions to go along with the library and to be referenced in your program.

    2. Alternatively, you can place your friends code in an include file and then reference it in your code some everything compiles together as one unit.

    3. Lastly, you can simply paste your friends code into your own and then compile the code as one unit.

    Professional programmers will also choose the first one as this makes things totally modular. It allows your friend to edit his code and you to edit your own and then you bring your code together at build time.

    Choice two has the drawback that if you do a compile and your friend is still making changes then it will stop you from building your code until he/she has fixed their compiler issues.

    Choice three has the drawback that you are basically grabbing a snapshot of your friends code and will need to delete and replace each time your friend makes changes.

    -- Jedi

    -------------------------------------------
    Your choice is simple: join us and live in peace, or pursue your present course and face
    obliteration. We shall be waiting for your answer. The decision rests with you.

    Klaatu, The Day The Earth Stood Still (1951)
     
  5. Apr 28, 2015 #4

    DrClaude

    User Avatar

    Staff: Mentor

    Thank you for clarifying my answer, jedishrfu. I often don't put more effort in my answers than the OP put in their questions :smile:
     
  6. Apr 28, 2015 #5

    jedishrfu

    Staff: Mentor

    Yes, we mentors are in awe of you Science Advisors and always look for the opportunity of one-upmanship.

    Take care
     
  7. Apr 28, 2015 #6

    Mark44

    Staff: Mentor

    Seems reasonable to me...
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook