※スタイルシート未対応ブラウザではレイアウトを正確に再現できません。
  > | advanced by | contents  | that returns in <    
                   < [modosusu] > Color magazine monochrome light and shade   font predetermined, Gothic Ming-style type longhand   size Konaka large   standard  


  Array of structures   

  1. ..clause 1..: Array of structures
  2. ..clause 2..: Argument of structure array

[1] Array of structures

The structure can be arranged. The method is similar to the current.
The following are examples of declaring the array of the structure variable with ten elements in the student type.


student data[10];
The usage is also quite the same as a current array.
The following are examples of the access to the structure array element specifying the element number.

data[1].year = 3;
strcpy(data[1].name,"MARIO");
How to use other points are also ..current array.. similar.

[   Another writing   ]
If the array of structures is used, writing other than explaining in the preceding clause can be done.
That is, the following three becomes the same meanings.

(*data).year
data->year
data[0].year
This writing can be used even by the structure pointer variable that is not the array.
However, both stopping is safer because it is troublesome.

By the way, to explain this three are quite the same meanings
It is necessary to understand the mechanism of the structure and the pointer firmly.
should? question your teacher and superior,
It cannot explain this and for a moment.

It returns to contents.


[2] Argument of structure array

Though it is possible to pass to the function by making the structure array an argument
In that case, it becomes how like a current array to pass it.
That is, it becomes shape to pass the address of the first element of the structure array.

In the received function, it is possible to treat as well as the argument of the current array.
Only the specified number displays contents of the student type in the following function.

 void student_print(student data[],int count)  
{
	int i;  
	for (i = 0;i < count;i++) { 
		printf("[学年]:%d\n",data[i].year); 
		Printf ("[ Class ]: %d\n" data[i].clas);      
		Printf ("[ Attendance number ]: %d\n" data[i].number);  
		Printf ("[ Name ]: %s\n" data[i].name);  
		Printf ("[ Height ]: %f\n" data[i].stature);  
		Printf ("[ Weight ]: %f\n" data[i].weight);  
	}
	return;
}
In this case, it becomes similar behavior to time when the array was passed.
When contents of the structure variable are changed having been passed ahead, the call origin is changed.

It returns to contents.


< - It is advanced -> | in | head that returns  to returning  next |.