when I do
FILE *f = fopen(...);
double k = 10;
fprintf(file, "k\x00%f", k);

only the string "k" will be written to the file (And this is the problem, since
I want the strings "k" and "10.0" to be separated by the symbol with the code
0).
If I do
fprintf(file, "k\0x20%f", k);
then the correct string "k 10.0" will be written to the file.

gcc -v:
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-mpfr --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 (Ubuntu 4.1.2-0ubuntu4)


-- 
           Summary: fprintf prints only a part of a string if the string has
                    \x00
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: andrei dot kouznetsov at gmail dot com


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

Reply via email to