rendered paste body#include <stdio.h>
#include <stdlib.h>
#include <randint.h>
#include <strings.h>
#define NAMES_FILE "monsternames.txt"
#define MAX_NAMES 30
#define MAX_NAME_LEN 12
#define MAX_WEAPON_LEN 16
#define MAX_WEAPONS 17
#define WEAPONS_FILE "weapons.txt"
#define ROOMS_FILE "rooms.txt"
#define MAX_ROOMS 2
#define MAX_ROOM_LEN 75
main() {
int b=0, d;
char buf[MAX_ROOM_LEN];
char *x = "%";
char *roomName[MAX_ROOMS];
FILE *rooms;
if((rooms = fopen(ROOMS_FILE, "r")) == NULL) {
printf("Couldn't open file %s\n", ROOMS_FILE);
exit(1);
} // end of if
while(b < MAX_ROOMS && fgets(buf, MAX_ROOM_LEN, rooms) != NULL) {
roomName[b] = malloc(MAX_ROOM_LEN);
memset(roomName[b], '\0', MAX_ROOM_LEN);
if ((strcmp(x,buf)) == 0) {
b++;
printf("same");
}
else {
strcat(roomName[b],buf);
}
}
system("pause");
for (b=0; b<MAX_ROOMS; b++) {
printf("%s",roomName[b]);
}
system("pause");
}