Back to index

glibc  2.9
bug1.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <string.h>
00004 
00005 int
00006 main (void)
00007 {
00008   char *bp;
00009   size_t size;
00010   FILE *stream;
00011   int lose = 0;
00012 
00013   stream = open_memstream (&bp, &size);
00014   fprintf (stream, "hello");
00015   fflush (stream);
00016   printf ("buf = %s, size = %Zu\n", bp, size);
00017   lose |= size != 5;
00018   lose |= strncmp (bp, "hello", size);
00019   fprintf (stream, ", world");
00020   fclose (stream);
00021   printf ("buf = %s, size = %Zu\n", bp, size);
00022   lose |= size != 12;
00023   lose |= strncmp (bp, "hello, world", 12);
00024 
00025   puts (lose ? "Test FAILED!" : "Test succeeded.");
00026 
00027   free (bp);
00028 
00029   return lose;
00030 }