What does it mean to define a structure in a .h file in C?


please eleaborate: give examples of elements of the structure and of an actual definition vs decleration

Thanks a lot!

4 Answers

  • 1 decade ago
    Favorite Answer

    Here is a page that will help.


    It has example files you can download.

    This page gives an example also, but it is pretty long and could be confusing.


  • 1 decade ago

    It means to declare all the elements of the structure in a .h file. The declaration is in the .h, and the actual definition goes into the .c file.

    Don't "define" in a .h file. It's bad style.

  • Anonymous
    1 decade ago

    An ".h" file is a C header file. It holds a variety of information about variables and constants needed to compile programs. When you create a struct in C, and you wish to reference it across all your source code, you place it in a header file, then include the header file in your program source.

    This is pretty basic stuff.

  • 1 decade ago

    .h means "Header"

    when you compile de .c file, that will be the source code "visible" to other C programs that want to access that one.

Still have questions? Get your answers by asking now.