- Reading a sequential access file.
–Create a FILE pointer, link it to the file to read.
myPtr = fopen( “myFile.dat”, “r” );
–Use fscanf to read from the file.
:Like scanf, except first argument is a FILE pointer.
fscanf( myPtr, “%d%s%f”, &myInt, &myString, &myFloat );
myPtr = fopen( “myFile.dat”, “r” );
–Use fscanf to read from the file.
:Like scanf, except first argument is a FILE pointer.
fscanf( myPtr, “%d%s%f”, &myInt, &myString, &myFloat );
–Data read from beginning to end.
--File position pointer – indicates number of next byte to be read/written.
:Not really a pointer, but an integer value (specifies byte location).
:Also called byte offset.
–rewind(myPtr) - repositions file position pointer to beginning of the file (byte 0).
--File position pointer – indicates number of next byte to be read/written.
:Not really a pointer, but an integer value (specifies byte location).
:Also called byte offset.
–rewind(myPtr) - repositions file position pointer to beginning of the file (byte 0).
No comments:
Post a Comment