CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: HELP! TYPEDEF

  1. #1
    Join Date
    May 1999
    Posts
    8

    HELP! TYPEDEF

    What do you make of this [1] thing in the code below. I have no clue. Your help will be greatly appreciated.

    typedef struct
    {
    int8 font;
    uchar path;
    } txtspec;
    typedef txtspec tspec[1];
    typedef tspec *tspecptr;
    typedef tspecptr *tspechandle;




    Thanks
    -ashes


  2. #2
    Join Date
    Apr 1999
    Posts
    383

    Re: HELP! TYPEDEF

    > typedef txtspec tspec[1];

    This makes tspec[1] a type synonym for txtspec. The syntax '[1]' is that of an array with one element, e.g:

    char foo[1]; // declares foo as an array of 1 char

    The typedef looks a bit unusual, but it's just another way of referring to the txtspec struct.

    Dave




  3. #3
    Join Date
    Apr 1999
    Posts
    8

    Re: HELP! TYPEDEF

    To clarify a bit, if you declare a variable of type tspec:

    tspec pfoo;

    pfoo will be a single-element array of txtspec. The following code would have the same result:

    txtspec foo;
    txtspec* pfoo = foo;


    /Michael Grundberg
    M.Sc. Computer Science
    Visionova IT-System, Sweden
    [email protected]


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured