You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the followed code run normal on linux with fmemopen(),but wiht your fmemopen on windows,the output is wrong,can you help to test it,thank you.the result should be "hello,world!".
Should work when you either call calloc() or fwrite(msg, 1, strlen(msg) + 1, fp): the point here is that Windows does not zero allocated memory (unless you use calloc(), while many Linuxes do. Your code is theoretically buggy as you forgot to write the NUL string sentinel, so you're riding system-specific and situation-dependent behaviour here.
the followed code run normal on linux with fmemopen(),but wiht your fmemopen on windows,the output is wrong,can you help to test it,thank you.the result should be "hello,world!".
====code====
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *write_to_buf(char *msg)
{
char *buf = (char *)malloc(1024);
}
int main(void)
{
char *str = "hello, world!";
char *buf = write_to_buf(str);
}
The text was updated successfully, but these errors were encountered: