C/Visual C - después de eer un fichero

 
Vista:

después de eer un fichero

Publicado por Nasón (40 intervenciones) el 19/03/2004 10:53:47
¿Cómo hago para, después de haber leído un fichero con fscanf, devolver el puntero de lectura/escritura al principio del mismo?
Compilo con VC++.

gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:después de eer un fichero

Publicado por J.Oliver Beltran (166 intervenciones) el 19/03/2004 11:14:11
Un truco muuuuuuuuuuuuy sencillo: Cierra el fichero y vuelvelo a abrir
;-P
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:después de eer un fichero

Publicado por Nicolas (183 intervenciones) el 19/03/2004 14:36:20
Usando FSEEK(.............);

La opcion q te dijo J.Oliver sirve y funciona, pero es correcto hacerlo de esa manera??????, pues NO .

Salu2!!!!!

Ayuda de la MSDN:

C Run-time Library for Windows CE


fseek
Moves the file pointer to a specified location.

Function Required Header
fseek <stdio.h>

int fseek( FILE *stream, long offset, int origin );
Parameters

stream
Pointer to FILE structure
offset
Number of bytes from origin
origin
Initial position
Libraries

All versions of the C run-time libraries.

Return Values

If successful, fseek returns 0. Otherwise, it returns a nonzero value. On devices incapable of seeking, the return value is undefined.

Remarks

The fseek function moves the file pointer (if any) associated with stream to a new location that is offset bytes from origin. The next operation on the stream takes place at the new location. On a stream open for update, the next operation can be either a read or a write. The argument origin must be one of the following constants, defined in Stdio.h:

SEEK_CUR
Current position of file pointer
SEEK_END
End of file
SEEK_SET
Beginning of file
You can use fseek to reposition the pointer anywhere in a file. The pointer can also be positioned beyond the end of the file. fseek clears the end-of-file indicator and negates the effect of any prior ungetc calls against stream.

When a file is opened for appending data, the current file position is determined by the last I/O operation, not by where the next write wo
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:después de eer un fichero

Publicado por xcfvgdcf (1 intervención) el 13/12/2008 00:06:57
hahahah, por que no es correcto hacerlo como dijo j oliver? nadamas por que tu dices? XD , no es la mejor forma, pero no significa que sea incorrecto.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar