buffer in C

Hello,

size_t write(int fd, const void *buf, size_t count)
{
    static size_t (*write_func)(int, const void *, size_t) = NULL;
    if (!write_func)
        write_func = (size_t(*)(int, const void *, size_t)) dlsym(RTLD_NEXT, "write");

   
    char tmp[count]; 
 
    memcpy(tmp,buf,count);
    printf("  %c \n",tmp[1]);
}

i try to dispaly tmp[1] but it displayed special characters like '?'
Have you an idea please
Thank you

1) You can't declare arrays with dynamic sizes like that.
2) The data already exists in memory. Why bother copying it?
3) Are special characters actually wrong? From your code I assume you're trying to overload write() using LD_PRELOAD. That means you're overloading every single write. Including ones involved in the symbol loading process, which happens before the program you want to override even runs. You don't just get the writes you consider relevant.
4) [1] is not the first element in the array. That's [0].

I did try to warn you weeks ago...

And it's:

ssize_t write( int fd, const void *buf, size_t count )

The signed result is critical in error conditions....

achele -

the OP wrote his own version of the write() syscall. It has caused loads of problems. So, there is no way for us to know exactly what the "write()" call is at the moment.