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

  • Thread starter Thread starter pursis
  • Start date Start date
  • Tags Tags
    Program
Click For Summary

Discussion Overview

The discussion revolves around how to integrate another program's code into a user's existing C program. It includes various methods for combining code, such as using libraries, include files, or direct code insertion.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant suggests compiling different parts as object files and linking them together.
  • Another participant proposes creating a library of the friend's code and calling its functions, along with creating an include file for function definitions.
  • A different approach mentioned involves placing the friend's code in an include file to compile everything as one unit.
  • Lastly, a participant discusses the option of directly pasting the friend's code into the user's program, noting the drawbacks of each method regarding modularity and the need for updates.

Areas of Agreement / Disagreement

Participants present multiple competing views on how to integrate code, with no consensus on a single best method. Each method has its pros and cons as discussed.

Contextual Notes

Limitations include potential issues with compilation if the friend's code is still being modified and the implications of choosing a more modular approach versus a direct code insertion.

Who May Find This Useful

Programmers and students looking to understand different methods of integrating code in C, particularly in collaborative environments.

pursis
Messages
1
Reaction score
0
I have to insert my friend coding in mine and I don't know how to do it can someone help me.
 
Technology news on Phys.org
  1. Compile the different parts as object files and link them together.
  2. #include
  3. Cut and paste
 
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)
 
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:
 
  • Like
Likes   Reactions: Borg and jedishrfu
Yes, we mentors are in awe of you Science Advisors and always look for the opportunity of one-upmanship.

Take care
 
DrClaude said:
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:
Seems reasonable to me...
 

Similar threads

  • · Replies 40 ·
2
Replies
40
Views
2K
Replies
38
Views
4K
Replies
86
Views
3K
  • · Replies 43 ·
2
Replies
43
Views
8K
  • · Replies 11 ·
Replies
11
Views
2K
Replies
37
Views
6K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 8 ·
Replies
8
Views
3K
Replies
33
Views
3K
Replies
16
Views
3K