Astruct
就像一个元组。您可以将其视为包含其他变量的变量。
struct globalArgs_t {
int noIndex;
char *langCode;
const char *outFileName;
FILE *outFile;
int verbosity;
char **inputFiles;
int numInputFiles;
} globalArgs;
// this function takes a pointer to a globalArgs_t struct
void myFunction(struct globalArgs_t *myStruct)
{
// we're using the operator '->' to access to the elements
// of a struct, which is referenced by a pointer.
printf("%i\n", myStruct->noIndex);
}
int main()
{
// We're using the operator '.' to access to the element of the structure
globalArgs.noIndex = 5;
myFunction(&globalArgs); // A structure is a variable, so it has an address
return 0;
}