If I open a file for writing and immediately close it: fclose(fopen("foo", "w")); the file "foo" will be truncated to zero length if it exists. However, I I do this with a memory buffer, e.g. char arr[] = { 'a','a','a','a','a','a','a','a','a','a', 0}; fclose(fmemopen(arr, 10, "w")); I would expect that arr[0] would have a null byte. But it doesn't. Is this a bug? -- Nick