235k views
21 votes
A structure, in C, has been given by: struct MYSTRUCT { char buf[15] shorts S int i; } * Select the proper keywords in the proper order) needed to declare, in C, an array of 8 structures (called MYSTR) of type MYSTRUCT. * Choose the following the expression for accessing Element 4 (i.e., index 4) of the char array (BUF) in the third element (i.e., index 3) of MYSTR. * Choose the statement to declare, in C, a pointer called MYSPTR that points to a structure of type MYSTRUCT. * Select the proper method to access the short, S, in a structure pointed to by MYSPTR by de-referencing the pointer.*Select the proper method to access the short, S, in a structure pointed to by MYSPTR by using the shorthand notation.

1 Answer

3 votes

Answer:

MYSTRUCT myStruct[8]; // statemnt to create an array of struct variables

myStruct[3].buf[4] // statement to access the fourth element of the array of the struct variables.

struct * MYSPTR = &myStruct; // This statement creates a pointer.

To dereference and access the S variable of the struct data structure in the array;

(*MYSPTR).S and its shorthand notation MYSPTR -> S

Step-by-step explanation:

A structure is a data structure in C language that is used to hold descriptive data of an object. The keyword struct is used to create the structure. An array of struct holds instances of a struct variable, where each struct can be accessed using the regular array indexing and the variables of the structs in the array can be accessed using dot notation.

User Olliezhu
by
3.0k points