I have a struct:
Code:
struct room
{char name[32];
char type[32];
int numConnections;
}
I have an array of these structs:
Code:
struct room rooms[7];
I am trying to create a function that returns a pointer to the struct that has the same name as what was passed into the function.
Code:
struct room *getRoomByName(const char* name)
{struct room *current;
for (int i = 0; i < 7; i++)
{
if ((strcmp(rooms[i].name, name) == 0))
{
*current = rooms[i];
}
}
return current;
}
*accidently hardcoded the name in that strcmp()
I pretty much have no idea what I'm doing.