gpt4 book ai didi

c - c中的指针和结构

转载 作者:太空宇宙 更新时间:2023-11-04 08:29:57 26 4
gpt4 key购买 nike

<分区>

我不知道如何访问我被迫使用的结构中的某个参数。该函数获取酒店和其中一位客人的护照号码,并返回客人入住的房间号,如果客人不在酒店,则返回 NOT_FOUND。

struct Guest
{
char name[20];
int passportNumber;
};


struct Room
{
int roomNumber;
int numOfGuests;
struct Guest* allGuests;//the Guests staying in the room
};


struct Hotel
{
int maxRooms;
int numOfUsedRooms;
struct Room** allRooms;
//array of Room* with physical size 'maxRooms'.
//only the first 'numOfUsedRooms' (logical size)
//rooms points to a room,all other pointers are
//NULL
};

int findGuestByPassportNumber(struct Hotel,int);

int main()
{
int i=0,j;
struct Hotel Cucamber;

printf ("before\n");//check

Cucamber.allRooms[i,i]->allGuests[i].name={"Spongebob"};

printf ("after\n");//check
Cucamber.allRooms[i,i]->allGuests[i].passportNumber=1234567890;
printf("%s",Cucamber.allRooms[i]->allGuests[i].name);

return 0;
}

程序甚至没有运行,因为代码块说:'{' 标记前的预期表达式。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com