Thread: a basic question..

  1. #1
    Compiling
    Join Date
    Jun 2003
    Posts
    69

    Question a basic question..

    Hello All,
    There's three data type I want to use for my programme: List, Binary search tree, and binomial queque, three header files and implementation files for them: list.h, tree.h, binomial.h || list.c, tree.c, binomial.c, respectively. Now I want to write a function in the binomial.c which can use all the functions in tree.c and list.c. I think I should modify the pre-processor part of the binomial.c, but I do not know how to do it, could anyone help me?? thx a lot!
    Last edited by NightWalker; 10-29-2003 at 07:11 AM.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Example:

    Code:
    File: main.c
    
    #include "functions.h"
    
    int main(void)
    {
      foo();
      return 0;
    }
    Code:
    File: functions.h
    #ifndef FUNCTIONS_H
    #define FUNCTIONS_H
    
    void foo(void);
    
    #endif
    Code:
    File: functions.c
    
    #include <stdio.h>
    #include "functions.h"
    
    void foo(void)
    {
      puts("inside foo!");
    }
    Code:
    Compiler:
    
    gcc main.c functions.c -o a.exe
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Compiling
    Join Date
    Jun 2003
    Posts
    69
    O...Sorry..
    I do not understand what u write..
    can u explain it to me?
    BTW: I already get these header and implementation files, I think the only thing I should do is just modify the pre-processor part binomial.c. The pre-processor part of the three .c files:
    list.c
    Code:
            #include "list.h"
            #include <stdlib.h>
            #include "fatal.h"
    tree.c
    Code:
            #include "list.h"
            #include <stdlib.h>
            #include "fatal.h"
    binomial.c
    Code:
            #include "binomial.h"
            #include "fatal.h"
    Last edited by NightWalker; 10-29-2003 at 07:17 AM.

  4. #4
    root
    Join Date
    Sep 2003
    Posts
    232
    >I want to write a function in the binomial.c which can use all the functions in tree.c and list.c.
    Include tree.h and list.h in binomial.c.
    The information given in this message is known to work on FreeBSD 4.8 STABLE.
    *The above statement is false if I was too lazy to test it.*
    Please take note that I am not a technical writer, nor do I care to become one.
    If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
    Don't assume that I'm ever entirely serious or entirely joking.

  5. #5
    Compiling
    Join Date
    Jun 2003
    Posts
    69
    and how could I compile the main file mian.c with the gcc compiler?
    Last edited by NightWalker; 10-29-2003 at 10:33 AM.

  6. #6
    Compiling
    Join Date
    Jun 2003
    Posts
    69
    sigh. could anyone answer my question?

  7. #7
    root
    Join Date
    Sep 2003
    Posts
    232
    >sigh. could anyone answer my question?
    Hammer did already, you just ignored him because it wasn't exactly what you wanted. Use gcc to compile and link the .c files:
    Code:
    gcc -o name list.c tree.c binomial.c main.c
    The information given in this message is known to work on FreeBSD 4.8 STABLE.
    *The above statement is false if I was too lazy to test it.*
    Please take note that I am not a technical writer, nor do I care to become one.
    If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
    Don't assume that I'm ever entirely serious or entirely joking.

  8. #8
    Compiling
    Join Date
    Jun 2003
    Posts
    69
    sorry, I am not very familiar with these gcc commands..

  9. #9
    root
    Join Date
    Sep 2003
    Posts
    232
    >sorry, I am not very familiar with these gcc commands..
    The manual is free and online
    The information given in this message is known to work on FreeBSD 4.8 STABLE.
    *The above statement is false if I was too lazy to test it.*
    Please take note that I am not a technical writer, nor do I care to become one.
    If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
    Don't assume that I'm ever entirely serious or entirely joking.

  10. #10
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>Hammer did already
    Hmm, my plan was that NW would learn from my post and adapt the ideas to suit. Oh well
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A basic math programming question
    By hebali in forum C Programming
    Replies: 38
    Last Post: 02-25-2008, 04:18 PM
  2. Basic question about GSL ODE func RK4
    By cosmich in forum Game Programming
    Replies: 1
    Last Post: 05-07-2007, 02:27 AM
  3. Basic question about RK4
    By cosmich in forum C++ Programming
    Replies: 0
    Last Post: 05-07-2007, 02:24 AM
  4. A very basic question
    By AshFooYoung in forum C Programming
    Replies: 8
    Last Post: 10-07-2001, 03:37 PM