Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

fgetc skips characters in binary file

booker
Beginner
807 Views
I have a simple 131 byte file that I am trying to read with fgetc using
ifort 10.1.008. Here is the code:

integer fgetc,ichar
integer i,j
character*1 ctmp

i=0
j=0
do while (j.ge.0)
j=fgetc(5,ctmp)
i=i+1
if(j.ge.0)then
write(6,'(i4,a,i4)')i,' ',ichar(ctmp)
else
write(6,*)'at EOF'
endif
end do

stop
end

This code reports only 130 bytes in the file. It is skipping the 41st byte which
happens to be an ascii code 13 (carriage return). There are however other identical
bytes elsewhere in the file. Both g77 and gfortran read the file correctly.
0 Kudos
1 Reply
Steven_L_Intel1
Employee
807 Views
Please report this to Intel Premier Support.
0 Kudos
Reply