The C program below prints the full string "xyz" both times. I am using

 GNU C version 4.1.2 20070925 (Red Hat 4.1.2-27) (x86_64-redhat-linux)
        compiled by GNU C version 4.1.2 20070925 (Red Hat 4.1.2-27).

-----------------------------------------------------------------------

#include <stdio.h>
#include <string.h>

 int main ( void )
 {
  char xyz[256];

  strcpy(xyz,"a not so random string");

  printf("\n  the string xyz is: \"%s\"\n\n",xyz);

  printf("\n  the 4 leftmost characters of xyz are: \"%4s\"\n\n",xyz);

  return 0;
 }


-- 
           Summary: printf does not process correctly the (bounded)
                    conversion specification of strings
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: paulo dot nogueira at ist dot utl dot pt


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37548

Reply via email to