how to create a header file in c++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shana
    New Member
    • Oct 2006
    • 20

    how to create a header file in c++

    Hi all,

    Can u tell me steps by step as how to create header file with my own defined functions and where to place it in TC folder. I tried to save it in INCLUDE but failed terribly.
  • arne
    Recognized Expert Contributor
    • Oct 2006
    • 315

    #2
    Originally posted by Shana
    Hi all,

    Can u tell me steps by step as how to create header file with my own defined functions and where to place it in TC folder. I tried to save it in INCLUDE but failed terribly.
    Did you try to put it in the same directory as your source code file?
    (What is TC, btw? Turbo-C?)

    Comment

    • Shana
      New Member
      • Oct 2006
      • 20

      #3
      Yes TC for Turbo C, I have created header file called "header.h" and saved in include, and then I have created function program and had saved in LIB. After that I wrote a main program which use that function and header file and saved it in bin. Now the prob is when I compile it, I do not get any error however executing the program gives linker error that it does not recognise the function.

      Comment

      • arne
        Recognized Expert Contributor
        • Oct 2006
        • 315

        #4
        Originally posted by Shana
        Yes TC for Turbo C, I have created header file called "header.h" and saved in include, and then I have created function program and had saved in LIB. After that I wrote a main program which use that function and header file and saved it in bin. Now the prob is when I compile it, I do not get any error however executing the program gives linker error that it does not recognise the function.
        I am not at all familiar with Turbo C I have to admit, but:
        - there should either be the concept of a "project" to which you add your header files; the IDE will then take care of compiling and linking all the stuff; or
        - you have to define an include path to tell the IDE where it can find the headers

        These are the typical approaches I would say.

        Did you try to store your headers in the same dir as you cpp files? This would be a starting point.

        Comment

        • Shana
          New Member
          • Oct 2006
          • 20

          #5
          yes i did try it, as far as i know the project thing is in Visual C++. Right now i cannot be online but I will come back tommorow with the enitre code as it is small program just to make sure that a header file can be created and linked with Turbo C++ libraries.

          Comment

          • rounak
            New Member
            • Feb 2007
            • 1

            #6
            hi! any one of u can teach me how i can make my own header file using turbo c++??????

            Comment

            • ppuniversal
              New Member
              • Feb 2007
              • 52

              #7
              I think ARNE is correct. You should set the path to the "include" directory.
              But here's a catch : If your IDE is supporting other programs, i.e. no linker errors are coming in other programs, then I think you should study the user manuals of TurboC++ get thinks right.
              Pawan

              Comment

              • shweta swini Dash
                New Member
                • Jul 2008
                • 2

                #8
                actually i want to step by procese how to make header file in tourbo c please sende me the procese

                Comment

                • shweta swini Dash
                  New Member
                  • Jul 2008
                  • 2

                  #9
                  Originally posted by arne
                  Did you try to put it in the same directory as your source code file?
                  (What is TC, btw? Turbo-C?)
                  yes i want to step by step procese how to create my own library header file in torbo c editer

                  Comment

                  • Kid Programmer
                    New Member
                    • Mar 2008
                    • 176

                    #10
                    In you main.cpp file or whatever you named it at the top did you put:
                    Code:
                    #include<header.h>
                    because if you didn't it wont work.

                    Comment

                    Working...