Results 1 to 3 of 3

Thread: 20 error in this code!

  1. #1

    Thread Starter
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Code:
    struct {
    	int iIndex;
    	char * szlabel;
    	char * szdesc;
    }
    This defines a structure. The next bit is just a statically-allocated array of these structures, initialised as you can see.
    Code:
    #define NUMLINES (int)(sizeof sysmetrics / sizeof sysmetrics [0])
    This cryptic-looking line is actually quite simple. It divides the size in bytes of the ENTIRE array by the size of one of those elements, giving the number of items entered. It's a quicker way that counting them and hard-coding that number.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  2. #2
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    OK, here is a simple one

    I saw this one too

    static
    {
    int index;
    char vari;
    }

    now you have closed the brakets and you define some like this

    thevar[]
    {
    1, "great",
    2, "then great"
    };

    why is:

    thevar[0].index = 1
    thevar[1].vari = "great"

    and

    thevar[1].index = 2
    thevar[1].vari = "then great"

    It is hard to explain it but that is something i am confised about beause you have just commas between two words and they are is certain variable.
    Baaaaaaaaah

  3. #3

    Thread Starter
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    It's shorthand for defining a struct:
    Code:
    struct x {
        int y;
        bool z;
    }
    
    x theStruct = {56, false};
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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