I have this method which reads a file but when I try to run it, it gives me an error for the return (char *) buffer. 
Error: warning: function returns address of local variable [-Wreturn-local-addr]
char * readFile(char* filename, size_t chunk) {
    FILE *proc;
    size_t len = chunk;
    char * buffer[len];
    proc = fopen(filename, "r");
    if(proc) {
        if(buffer) 
            fread(buffer, 1, len, proc);
        fclose(proc);
        return (char *) buffer;
    }return "error";
}
Should I be creating the buffer before the method outside the main for this method?
PS: I am aware this might be a duplicate question.
 
    