Thread: how to call a C function from another file

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    2

    Exclamation how to call a C function from another file

    hi,


    I want to call a C function from another file.
    I want to call fun1() from secondfile.c into mymain.c file.
    main () is located in mymain.c .

    Code:
    main ()
    {
     fun1();
    }
    how can I call it.

    can I include the file secondfile.c in mymain.c.

    give me an example program .

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Don't include it. Link it. Put your function prototypes in a header file, include that. Search the forum,this sort of thing gets asked all the time.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Create an interface and an implementation.
    http://faq.cprogramming.com/cgi-bin/...&id=1043284392
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  2. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  5. Replies: 3
    Last Post: 03-04-2005, 02:46 PM