about summary refs log tree commit diff
path: root/manual/examples/memstrm.c
diff options
context:
space:
mode:
Diffstat (limited to 'manual/examples/memstrm.c')
-rw-r--r--manual/examples/memstrm.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/manual/examples/memstrm.c b/manual/examples/memstrm.c
new file mode 100644
index 0000000000..1674c36e0b
--- /dev/null
+++ b/manual/examples/memstrm.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+
+int
+main (void)
+{
+  char *bp;
+  size_t size;
+  FILE *stream;
+
+  stream = open_memstream (&bp, &size);
+  fprintf (stream, "hello");
+  fflush (stream);
+  printf ("buf = `%s', size = %d\n", bp, size);
+  fprintf (stream, ", world");
+  fclose (stream);
+  printf ("buf = `%s', size = %d\n", bp, size);
+
+  return 0;
+}