It's always better to break down a task into smaller tasks
Maybe you can work with this skeleton

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void read_file(char* name){
    printf("Filename received: %s\n", name);
    // TO DO add your logic
}

void process_file(char *name)
{
    printf("Processing: %s", name);
    // TO DO 
    // open file and read all filenames using read_line 
    // send each filename to read_file 
}

char *read_line(char *buffer, int buf_size, FILE *stream)
{
    if(!fgets(buffer, buf_size, stream))
        return NULL;
    char *pos = strchr(buffer, '\n');
    if(pos)
        *pos = '\0';
        
    return buffer;
}


int main()
{
    char name[256] = "";
    printf("Enter filename: ");
    read_line(name, 255, stdin);
    process_file(name);
}