Correct way of using struct?

This is a discussion on Correct way of using struct? within the C Programming forums, part of the General Programming Boards category; My instructor said to me that the correct way of using a struct always should be done in a .c ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,590
    > 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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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,006
    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, 10: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, 08:09 PM
  5. towers of hanoi problem
    By aik_21 in forum C Programming
    Replies: 1
    Last Post: 10-02-2004, 01:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21