1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Rep Power

    COORD coord={0,0}

    Hello there.
    While i was browsing i found this piece of code

     #include <stdio.h>    
      COORD coord={0,0}; 
     void gotoxy(int x,int y)
    I would appreciate some info on this line
    --->COORD coord={0,0};
    Is it just a struct?
    Is it defining a struct?
    Is this --> coord={0,0} a way to input data to a struct?
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Rep Power
    COORD is the type (it could be a struct)
    coord is the variable name
    {0,0} is an initialisation list.

    If it is a struct, then the first two members of the struct will be explicitly initialised to zero.

    If it is a struct with more than two members, all remaining members will be implicitly initialised to zero / '\0' / 0.0 / NULL (according to the member type).
    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
  4. #3
  5. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Rep Power
    COORD is a struct. We know this not only because union doesn't make sense, but also because the member access is dotted:


    While it's been a long time since I initialized a struct this way, it looks right. You'd use data of the correct type in the order left to right within top to bottom to initialize members.

    COORD coord; /* sufficient to define a struct */

    windows.h probably contains (or includes)

    typedef struct coord {
    int x,y;
    } COORD;
    [code]Code tags[/code] are essential for python code and Makefiles!
  6. #4
  7. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Rep Power
    No, it's not defining COORD, since that's already defined elsewhere; ie, in windows.h.

    Why not Google for it at MSDN (MicroSoft Developers' Network)? Or open windows.h and do a find? Though it's likely that it's in another header file that's #include'd in windows.h, so you may need to grep for it in the INCLUDES directory. Or why not simply look it up in your IDE's help file? Any of those methods would have yielded the answer to your question much more quickly and reliably than posting it on a forum.

    BTW, it is a struct: http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
    But then you should be just as capable as I am at using Google.

IMN logo majestic logo threadwatch logo seochat tools logo