Q: Passing a string array to a function to be altered so currently I am running a program to generate a bundle of files at random, then have them connect to each other, and create a maze like game. 
I'm trying to build an array of the file paths to pass to a function so it can be generated then the array can be worked on some more by the calling function. What's happening is that is generating the array but leaving the first element(filepath[0]) blank thus seg. faulting on me. But when I set a breakpoint, all other sections of the array are fine, just not the first element. It's been about 9 months since I wrote and C and I'm unsure where my pointer hiccup is coming from, thank you all in advanced
Here is the code so far 
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <stdbool.h>

void create_files(char (*filepath[7]));

int main(){
    time_t t;
    char *filepath[7];
    srand((unsigned) time(&t));
    int i = 0;
    for (i = 0; i < 7; i++)
        filepath[i] = malloc(60);


    create_files(filepath);
    for (i = 0; i < 7; i++)
        free(filepath[i]);
    return 0;
}

void create_files(char (*filepath[7])){
    int i = 0, pid = getpid(),q = 0,random, r=7;
    char procid[20];
    sprintf(procid, "%d", pid);
    char directory[80] = "./dringb.rooms.";

    strcat(directory,procid);
    int newdir = mkdir(directory, 0777);

    for (q = 0; q < 7; q++)
        filepath[q] = directory;

    char *bigrooms[10] ={"/Bridge.txt","/Gate.txt","/Hallway.txt",
        "/Dungeon.txt","/Galley.txt","/Throne.txt","/Boss.txt", "/Lab.txt",
        "/Torture.txt", "/Courtyard.txt"};
    bool redflag = false;
    char *rooms[7];
    q = 0;

    while (q != 7){ //grabs the rooms at random from the set of bigrooms
        random = rand()%10;
        for(i = 0; i < 7; i++){
            if (rooms[i] == bigrooms[random])
                redflag = true;
        }
        if (redflag == false){
            rooms[q] = bigrooms[random];
            redflag = false;
            q++;
        }
        else
            redflag = false;
    }

    char **dest = (char **)malloc(r * sizeof(char *));
    for (i=0; i<r; i++)
        dest[i] = (char *)malloc(8 * sizeof(rooms)); //allocates each room a new space

    for (i = 0; i < 7; i++){
        strcat(dest[i], directory);
        strcat(dest[i],rooms[i]);
        filepath[i] = dest[i]; //creates directory path for each room.txt
    }


    int usedrooms[4];
    for (i = 0; i < 7; i++){
        FILE *f = fopen(filepath[i], "w");
        fputs("Roomname: ", f);
        fputs(rooms[i],f);
        fputs("\n",f);
        fclose(f);
    }

    for (i = 0; i < 7; i++){
        FILE *f = fopen(filepath[i], "a+");
        for (q = 0; q < 4; q++)
            usedrooms[q] = 100;
        int roomrand, q = 0, z = 0, connrooms = 3;
        bool greenflag = true, retry = false;

        roomrand = rand() %2;
        if (roomrand == 1)
            connrooms = 4;

        while (q != connrooms){ //prevents from having a connection to same room
            do{
                retry = false;
                roomrand = rand() % 7;
                for(z = 0; z < 4; z++){
                    if (roomrand == usedrooms[z])
                        retry = true;
                }
            }while(roomrand == i || retry == true); //prevents from having a connection to same room
            bool found = false;
            char buffer[100];
            rewind(f);
            while(fscanf(f,"%s", buffer) == 1){
                if (strcmp(buffer,rooms[roomrand]) == 0)//prevents a double connecting room from being added
                    greenflag = false;
            }
            if(greenflag == true){
                usedrooms[q] = roomrand;
                fputs("Connecting Room: ", f);
                fputs(rooms[roomrand],f);
                fputs("\n",f);
            }

            fclose(f);
            greenflag = true;
            found = false;
            FILE *f2 = fopen(filepath[roomrand],"a+");
            rewind(f2);
            while(fscanf(f2,"%s", buffer) == 1){
                if (strcmp(buffer,rooms[i]) == 0) //prevents a double connecting room from being added
                    found = true;
            }
            if (found == false){
                fputs("Connecting Room: ",f2);
                fputs(rooms[i],f2);
                fputs("\n",f2);
            }
            fclose(f2);
            fopen(filepath[i],"a+");
            found = false;
            q++;
        }
        q = 0;
        fclose(f);
    }

    int usedroomtype[7];
    int roomrand;
    for (i = 0; i < 7; i++)
        usedroomtype[i] = 100;

    for (i = 0; i < 7;i++){
        do{
            redflag = false;
            roomrand = rand() % 7;
            for (q = 0; q < 7; q++)
                if (roomrand == usedroomtype[q])
                    redflag = true;
        } while (redflag == true);
        usedroomtype[i] = roomrand;
        FILE *fp = fopen(filepath[roomrand], "a+");
        if (i == 0)
            fputs("Room Type: Start Room", fp);
        else if (i == 6)
            fputs("Room Type: End Room",fp);
        else
            fputs ("Room Type: Mid Room",fp);
        fclose(fp);
    }

}


A: The array is being passed correctly. The problem is that data is getting corrupted.
for (q = 0; q < 7; q++)
    filepath[q] = directory;

This is invalid. It should be strcpy(filepath[q], directory); It's okay to set for example char *temp = filepath[q], because temp was not allocated. But filepath[q] is already allocated. Use strcpy to to change it value. 
Later there is a similar error
char **dest = (char **)malloc(r * sizeof(char *));
for (i=0; i<r; i++)
    dest[i] = (char *)malloc(8 * sizeof(rooms));

for (i = 0; i < 7; i++){
    strcat(dest[i], directory);
    strcat(dest[i],rooms[i]);
    filepath[i] = dest[i]; //creates directory path for each room.txt
}

Two things. First, dest is not initialized. Always start with strcpy with uninitialized string, then use strcat. Second, use strcpy to change the value of filepath[i] as explained earlier. dest is actually not needed. You could just copy directly to filepath
for (i = 0; i < 7; i++)
{
    strcpy(filepath[i], directory);
    strcat(filepath[i], rooms[i]);
}

As mentioned in comments, allocation for filepath should be larger. directory is max 80 bytes, room is max 10 bytes, so filepath should be max 90 bytes.
for (i = 0; i < 7; i++)
    filepath[i] = malloc(90);

Also some values are not initialized, example char *rooms[7];
Elsewhere:
int pid = getpid();
char procid[20];
sprintf(procid, "%d", pid);
char directory[80] = "./dringb.rooms.";
strcat(directory,procid);

You are already using sprintf, you can simplify this as follows:
sprintf(directory, "./dringb.rooms.%d", getpid());

Example:
int main()
{
    time_t t;
    srand((unsigned) time(&t));

    char *filepath[7];
    int i = 0;
    for (i = 0; i < 7; i++)
        filepath[i] = malloc(90);

    create_files(filepath);

    for (i = 0; i < 7; i++)
        printf("%s\n", filepath[i]);

    for (i = 0; i < 7; i++)
        free(filepath[i]);

    return 0;
}
void create_files(char *filepath[7])
{
    int i = 0, random;
    char directory[80];
    sprintf(directory, "./dringb.rooms.%d", getpid());
    //mkdir(directory);
    mkdir(directory, 0777);

    int q;
    for (q = 0; q < 7; q++) strcpy(filepath[q], directory);

    char *bigrooms[20] ={"/Bridge.txt","/Gate.txt","/Hallway.txt","/Dungeon.txt","/Galley.txt","/Throne.txt","/Boss.txt", "/Lab.txt","/Torture.txt", "/Courtyard.txt"};
    bool redflag = false;
    char *rooms[7];
    for (i = 0; i < 7; i++) rooms[i] = 0;

    q = 0;
    while (q != 7)
    {
        //grabs the rooms at random from the set of bigrooms
        random = rand()%10;
        for(i = 0; i < 7; i++)
        {
            if (rooms[i] == bigrooms[random])
                redflag = true;
        }

        if (redflag == false)
        {
            rooms[q] = bigrooms[random];
            redflag = false;
            q++;
        }
        else
            redflag = false;
    }

    for (i = 0; i < 7; i++)
    {
        strcpy(filepath[i], directory);
        strcat(filepath[i], rooms[i]);
    }

    int usedrooms[4];
    for (i = 0; i < 7; i++)
    {
        FILE *f = fopen(filepath[i], "w");
        fputs("Roomname: ", f);
        fputs(rooms[i],f);
        fputs("\n",f);
        fclose(f);
    }

    for (i = 0; i < 7; i++)
    {
        FILE *f = fopen(filepath[i], "a+");
        for (q = 0; q < 4; q++)
            usedrooms[q] = 100;
        int roomrand, q = 0, z = 0, connrooms = 3;
        bool greenflag = true, retry = false;

        roomrand = rand() %2;
        if (roomrand == 1)
            connrooms = 4;

        while (q != connrooms)
        { //prevents from having a connection to same room
            do
            {
                retry = false;
                roomrand = rand() % 7;
                for(z = 0; z < 4; z++)
                {
                    if (roomrand == usedrooms[z])
                        retry = true;
                }
            }
            while(roomrand == i || retry == true); //prevents from having a connection to same room

            bool found = false;
            char buffer[100];
            rewind(f);
            while(fscanf(f,"%s", buffer) == 1)
            {
                if (strcmp(buffer,rooms[roomrand]) == 0)//prevents a double connecting room from being added
                    greenflag = false;
            }

            if(greenflag == true)
            {
                usedrooms[q] = roomrand;
                fputs("Connecting Room: ", f);
                fputs(rooms[roomrand],f);
                fputs("\n",f);
            }

            fclose(f);
            greenflag = true;
            found = false;
            FILE *f2 = fopen(filepath[roomrand],"a+");
            rewind(f2);

            while(fscanf(f2,"%s", buffer) == 1)
            {
                if (strcmp(buffer,rooms[i]) == 0) //prevents a double connecting room from being added
                    found = true;
            }

            if (found == false)
            {
                fputs("Connecting Room: ",f2);
                fputs(rooms[i],f2);
                fputs("\n",f2);
            }

            fclose(f2);
            fopen(filepath[i],"a+");
            found = false;
            q++;
        }
        q = 0;
        fclose(f);
    }

    int usedroomtype[7];
    int roomrand;
    for (i = 0; i < 7; i++)
        usedroomtype[i] = 100;

    for (i = 0; i < 7; i++)
    {
        do
        {
            redflag = false;
            roomrand = rand() % 7;
            for (q = 0; q < 7; q++)
                if (roomrand == usedroomtype[q])
                    redflag = true;
        }
        while (redflag == true);

        usedroomtype[i] = roomrand;
        FILE *fp = fopen(filepath[roomrand], "a+");
        if (i == 0)
            fputs("Room Type: Start Room", fp);
        else if (i == 6)
            fputs("Room Type: End Room",fp);
        else
            fputs ("Room Type: Mid Room",fp);
        fclose(fp);
    }
}

