use sprintf() or similar to create the pathFilename string:
char pathFile[MAX_PATHNAME_LEN];
sprintf(pathFile, "%s\\my_log.txt", directory );
then
int filedescriptor = open(pathFile, O_RDWR | O_APPEND | O_CREAT);
Note: If you are using linux, change \\
to /
and MAX_PATHNAME_LEN to 260 (or whatever linux likes to use for that value.)
EDIT if you need to check that a directory exists before creating a file there, you can do something like this:
if (stat("/dir1/my_dir", &st) == -1) {
mkdir("/dir1/my_dir", 0700);
}