Update.
[glibc.git] / stdio-common / bug1.c
blob455b14d7cf410618caab337b1dbe978e95fd7de7
1 #include <stdio.h>
2 #include <string.h>
4 int
5 main (void)
7 char *bp;
8 size_t size;
9 FILE *stream;
10 int lose = 0;
12 stream = open_memstream (&bp, &size);
13 fprintf (stream, "hello");
14 fflush (stream);
15 printf ("buf = %s, size = %d\n", bp, size);
16 lose |= size != 5;
17 lose |= strncmp (bp, "hello", size);
18 fprintf (stream, ", world");
19 fclose (stream);
20 printf ("buf = %s, size = %d\n", bp, size);
21 lose |= size != 12;
22 lose |= strncmp (bp, "hello, world", 12);
24 puts (lose ? "Test FAILED!" : "Test succeeded.");
26 return lose;