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

Update:

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

Thanks a lot!

4 Answers

Relevance
  • 10 years ago
    Best Answer

    Here is a page that will help.

    http://www.scss.tcd.ie/Martin.Emms/NLP/C++_notes/n...

    It has example files you can download.

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

    http://www.color.org/profileheader.txt

  • 10 years 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
    10 years 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.

  • 10 years 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.