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

  • Thread starter Thread starter pursis
  • Start date Start date
  • Tags Tags
    Program
AI Thread Summary
To integrate a friend's code into your own project, there are several methods to consider. One effective approach is to create a library from your friend's code, which allows you to call their functions while maintaining modularity. This method enables both you and your friend to make changes independently, compiling only when needed. Alternatively, you can place your friend's code in an include file to compile everything as a single unit. However, this may lead to issues if your friend is still making changes during compilation. The simplest method is to directly paste your friend's code into your project, but this creates a static snapshot that requires manual updates whenever changes are made. Each method has its pros and cons, with the library approach being favored for its flexibility and modularity.
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 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...
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top