简体   繁体   中英

Trying to figure out name of data struct

While going through some code, I came accross this block of code:

struct option options[] = {
    {"help", 0, 0, HELP_OPTION},
    {"minor", 1, 0, MINOR_OPTION},
    {"dac", 1, 0, DAC_OPTION},
    {0, 0, 0, 0}
};

I know what a struct is, but I have never seen a "{0, 0, 0, 0}" data struct. Does anyone know what the name for the "{0,0,0,0}" data struct is?

The code simply defines an array that contains several instances of option structures. In this case, the { 0, 0, 0, 0 } is probably used to signify that it is the last item in the array (since C arrays don't have a length property).

As far as the name, it is unnamed. You can reference this structure from code using options[3] .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM