作者:sean | 来源:互联网 | 2023-05-18 15:57
Imtryingtomakeaprogramthatusesastructurepointedbyanarrayof30.Whichmeans,therewil
I'm trying to make a program that uses a structure pointed by an array of 30. Which means, there will be only 30 available structures named Person. Think of this as an Activity line, the Activity line can only have 30 active Persons. Functions used are:
我正在尝试制作一个程序,它使用一个由30个数组指向的结构。也就是说,只有30个可用的结构命名为Person。认为这是一个活动线,活动线只能有30个活动人士。功能使用:
#include
#include
struct Person
{
char name[40];
char firstname[40];
int CIN[12];
};
typedef struct Person *Activity;
main()
{
Activity act[30];
return 0;
}
Vacant(searches if there is an empty place in the Activity line).
空(如果活动行中有一个空位置)。
insertion(Inserts new Persons IF a place is empty in the Activity line).
插入(如果活动线中的位置为空,则插入新的人员)。
withdrawal(Removes a Person from the Activity line).
退出(从活动行中删除一个人)。
This is the declaration of the structure and the Activity line:
这是结构和活动线的声明:
CIN is French for National Card Identity.
CIN在法语中是“身份证”的意思。
The functions are:
功能有:
vacant(Activity act, int index);
insertion(Activity act, int index);
withdrawal(Activity act);
index is the number of the empty place, must be used in insertion.
索引是空白处的数目,必须用于插入。
My questions are:
我的问题是:
- Is the declaration I made correct?
- 我的声明是正确的吗?
- If; considering the declaration is correct, the size of the array is 30 and the array points to the structure, does it mean I don't need to allocate the memory dynamically?(Using malloc function).
- 如果;考虑到声明是正确的,数组的大小为30,数组指向结构,这是否意味着我不需要动态地分配内存?(使用malloc函数)。
- Considering I'm on the right path. Does accesing field "name" for example go like this: "act.name"?
- 考虑到我在正确的道路上。例如,accesing字段的“name”是这样的:“act.name”?
1 个解决方案