0

My goal is to print out the string even if it's not assigned (but is declared with a certain length). My code is:

program test
   
   use, intrinsic :: iso_fortran_env, only : stderr=>error_unit
   
   implicit none
   
   character(len=1024) :: file_update
   
   write (stderr, '(a)') 'file-update: '//file_update
   
end program test

When I run the above code, the output is:

file-update: �UdG��tdG�|gCG��m�F� dCG� ��3���3�P��3��UdG� �eG���eG�1
DG��UdG���g��<�CG�U��B�jdG�DG����3����3��cCG����3��dCG�<�CG����3������jdG�DG�0fCG�<�CG�0��F���G��G����F�pdG�1
DG�XmdG��pdG�ȡeG�0��F�p��3�XsdG����3����F��G����F��G��pdG�1
DG�XmdG��pdG�ȡeG�0��F�p��3�XsdG����3��7�G�

My expectation is to output something like file-update: because it is an empty string. But why it gives me a bunch of strange characters? How can I fix it?

janet
  • 31
  • 1
  • `file_update` is not an empty string: it has not been given a value at all (it is _undefined_). You are not allowed to print such things. – francescalus Aug 20 '21 at 19:09

0 Answers0