Pues estoy haciendo algo con ficheros y tengo un pequeño problema. Necesito abrir un fichero secuencial para escritura/lectura y poder escribir, leer o modificar un registro en una posición X. Para ello uso fseek() y situo el cursor en la posición que me interesa.
El fseek funciona perfectamente, y puedo leer cualquier posición, pero cuando se escribe se va al fin de fichero...
"a+" | Open a file for reading and appending. All writing operations are performed at the end of the file, protecting the previous content to be overwritten. You can reposition (fseek, rewind) the internal pointer to anywhere in the file for reading, but writing operations will move it back to the end of file. The file is created if it does not exist.
¿Hay alguna forma de evitar eso, o debo estar cambiando de modo manualmente cada vez que quiera hacer una operación?
Saludos!