public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* fmemopen question
@ 2023-10-12 14:57 Nick Stoughton
  2023-10-16 21:34 ` Adhemerval Zanella Netto
  0 siblings, 1 reply; 2+ messages in thread
From: Nick Stoughton @ 2023-10-12 14:57 UTC (permalink / raw)
  To: libc-help

[-- Attachment #1: Type: text/plain, Size: 390 bytes --]

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-16 21:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-12 14:57 fmemopen question Nick Stoughton
2023-10-16 21:34 ` Adhemerval Zanella Netto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).