two *.c files to one?

This is a discussion on two *.c files to one? within the C Programming forums, part of the General Programming Boards category; I made a program, and I would like to add this other program I made to it also. But I ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    43

    Question two *.c files to one?

    I made a program, and I would like to add this other program I made to it also. But I dont want to type in the program and make it a function. Is there a faster way to to link them?

    I want this [Namemean.c] in [MazeV1.3.c].
    ()()() MonKey ware
    Kyle J. R.

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    What's the goal of this? Are you making a menu in which one can choose which program to run? In that case you could rename the main of the program in Namemean.c to something like main_of_namemean and call this in the other program. Perhaps you'll need to restructure the function a little bit, but since main is just a function, it should work.

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Originally posted by Goof Program
    I made a program, and I would like to add this other program I made to it also. But I dont want to type in the program and make it a function. Is there a faster way to to link them?

    I want this [Namemean.c] in [MazeV1.3.c].
    You *could* just #include "Namemean.c" in the beginning of MazeV1.3.c, which is the same as pasting that code to that position.
    However this in not the right way to do this. You have to use the linker. I've had problems with linking, so I'm not the right person to ask
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  4. #4
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    >You *could* just #include "Namemean.c" in the beginning of
    >MazeV1.3.c,

    If both Namemean.c and the other file have a main-function, then you'll get errors. A program can't have to main functions.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. add source files to embedded VC 4.0
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 03:28 AM
  2. *.cpp and *.h files understanding
    By ElastoManiac in forum C++ Programming
    Replies: 4
    Last Post: 06-11-2006, 04:45 AM
  3. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 10:46 AM
  4. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 01:41 PM
  5. header and source files
    By gtriarhos in forum C Programming
    Replies: 3
    Last Post: 10-02-2005, 03:16 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21