-
Notifications
You must be signed in to change notification settings - Fork 0
/
rooms.c
41 lines (38 loc) · 964 Bytes
/
rooms.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdio.h>
#include <stdlib.h>
#include "rooms.h"
#include "items.c"
#include "items.h"
#include <time.h>
#define ROOM_NUMBER 9
#define CHARACTER_NAMES 9
int i,random_number, count=10;
int flag=1;
char *rooms_names[ROOM_NUMBER]={"Kitchen", "Ballroom", "Conservatory", "Dining Hall", "Billiard Room", "Library", "Lounge", "Study", "Hall"};
char *character_name;
/*This method generates random number using srand and rand functions.
Swaps the room at i index and the room at the random number index from the rooms_names array
*/
void fisher_yates(char **rooms_names){
char *swap;
srand(time(NULL));
for(i=8; i>0; i--){
random_number=rand()%(i+1);
swap=rooms_names[i];
rooms_names[i]=rooms_names[random_number];
rooms_names[random_number]=swap;
}
}
int compare(char one[],char two[])
{
i=0;
while(one[i]!='\0' && two[i]!='\0')
{
if(one[i]!=two[i])
{
return 1;
}
i++;
}
return 0;
}