dot operator before member variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Time
    New Member
    • Jan 2010
    • 77

    dot operator before member variable

    hi,
    I have seen . operator used while defining structure before name of variable?
    ex.
    struct usb_driver stub_driver = {
    .name = "usbip",
    .probe = stub_probe,
    .disconnect = stub_disconnect ,
    .id_table = stub_table,
    };
    What is that, does someone know?
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Not in standard C89 or C++ you haven't.

    This is a part of the C99 standard and it allows you to specifically initialise members of a structure, all other members of the structure are initialised to 0.

    The . is just part of the syntax for this type of initialisaer and comes before the structure member name.

    Comment

    • Time
      New Member
      • Jan 2010
      • 77

      #3
      But then what is the type of those variables?....d ata type?? char,float,int? ?
      Is it the case that it takes its type according to initialized value of it?

      Comment

      • newb16
        Contributor
        • Jul 2008
        • 687

        #4
        No , their types are already specified in struct usb_driver structure.

        Comment

        Working...