c - Reading from a file opened using append mode -


it might dumb question modifying else's code , seems need read file opened in append mode. tried fseek beginning of file nothing being read. know can change mode rw wanted know why fseek not working. in man page write ignores fseek nothing read though.

there 1 pointer @ start of file when write operation attempted moved end of file. can reposition using fseek or rewind anywhere in file reading, writing operations move end of file.

when open in append mode, file pointer returned end of file before every write. can reposition pointer fseek reading, call function writes file, pointer goes end of file.

the answer @ does fseek() move file pointer beginning of file if opened in "a+b" mode? references appropriate section of c standard.

use "w+" mode if write arbitrary places in file. existing file overwritten.

if append existing file initially, fseek arbitrary place, use "r+" followed

fseek(f, 0, seek_end) 

hope helps..


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -