Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

C Null char in format statment

andrew_4619
Honored Contributor III
5,832 Views

Hopefully an easy question, consider the code snip:

        character(20) :: gbuf
        write(gbuf,1) flt,char(0)
        1 format(f10.3,A)

Given format 1 is used many times it would be neater if the null character termination was in the format rather than the write. I just spend a few minutes scratching my head and googleing.... Any ideas?

0 Kudos
44 Replies
Steven_L_Intel1
Employee
556 Views

That is interesting and a bug. Writing the data to a file shows me that the run-time format does write the NUL whereas the embedded format does not. Issue ID is DPD200414360.

0 Kudos
andrew_4619
Honored Contributor III
556 Views

Amazing what a can of worms my simple question back in 2014 opened!

0 Kudos
Steven_L_Intel1
Employee
556 Views

It does reinforce an old saying that "If the same operation is coded in two places, one of them is wrong".

0 Kudos
Reply