Thread: Correct way of using struct?

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    37

    Correct way of using struct?

    My instructor said to me that the correct way of using a struct always should be done in a .c file instead in a header file. BUT he couldn't explain why a struct should be in a .c file.

    Can anyone tell me more about this?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > Can anyone tell me more about this?
    Perhaps your instructor is clueless - it seems to me that he is
    Have a look in say time.h, that contains 'struct tm'
    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.

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    37
    I have now talked to another intructor and he said that placing struct in .h or a .c file makes no difference.

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    There is a difference, especially if you ever plan on having your projects take up more than one file. Fire your instructors.

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

  5. #5
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by Mikro
    My instructor said to me that the correct way of using a struct always should be done in a .c file instead in a header file. BUT he couldn't explain why a struct should be in a .c file.
    Was this really not about structs per se, but about declaration and definition?
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with struct... not returning correct results.
    By drty2 in forum C Programming
    Replies: 7
    Last Post: 01-18-2009, 11:25 PM
  2. Help please im stuck
    By ItsMeHere in forum C Programming
    Replies: 7
    Last Post: 06-15-2006, 04:07 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Binary Tree, couple questions
    By scoobasean in forum C Programming
    Replies: 3
    Last Post: 03-12-2005, 09:09 PM
  5. towers of hanoi problem
    By aik_21 in forum C Programming
    Replies: 1
    Last Post: 10-02-2004, 01:34 PM