default values for Struct elements

This is a discussion on default values for Struct elements within the C Programming forums, part of the General Programming Boards category; Can we set default values for a struct?...

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    3

    default values for Struct elements

    Can we set default values for a struct?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,506
    Not in C.

    In C++, you could provide a default constructor.
    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
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,831
    When defining: struct ... = { value, value, ...}
    Like that? Initialization.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with project
    By chrisa777 in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2006, 05:01 PM
  2. Replies: 1
    Last Post: 02-03-2005, 02:33 AM
  3. Serial Communications in C
    By ExDigit in forum Windows Programming
    Replies: 7
    Last Post: 01-09-2002, 09:52 AM
  4. Adding Default values to controls in Dialog boxes
    By juhigarg in forum C++ Programming
    Replies: 3
    Last Post: 11-06-2001, 11:44 PM
  5. Default values in function prototypes
    By wdicks in forum C Programming
    Replies: 13
    Last Post: 10-10-2001, 01:06 AM

Tags for this Thread


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