Conversation

can some wizard explain why i can’t get the file into my string?

long file(char *req_path, char *res_body)
{
    FILE *file = fopen(req_path, "r");
    long n;

    struct stat st;
    stat(req_path, &st);
    n = st.st_size;

    if(fread(res_body, 1, (size_t)n, file) != (size_t)n){
        return -1;
    }

    res_body[n+1] = '\0';
    fclose(file);
    return n;
}

the string is big enough

0
0
1
could i mmap that and give the pointer to send?
0
0
0
seriously, what is this shit?
0
0
0
@snacks damn, I hardly understand that code…
1
0
1
@duponin i'm the best at c. This code is probably just too high level for you
1
0
0
@snacks
sure you are
Don't you more mean low-level? (more near to the machine)
1
0
0
@duponin no, i mean abysmally confused
2
0
0
@duponin and having worked on this way too long
1
0
0
@snacks Take some rest and you will understand your code later
1
0
0
@duponin i should sleep in 30 minutes
2
0
0
@snacks You go to sleep early, that's cute
1
0
0
@duponin and i haven't worked on this piece of shit for over 3 hours
0
0
0
@duponin i need to get up at 6 and i'm always really fucked when i don't get my 8 hours for a while
0
0
1
@duponin and i slept less than 5 today
1
0
0
@snacks I totally see what you are talking about
I have the same but I totally lack of sleep
0
0
1