Transferring SdFile object to another function

Hi everybody, I’m quite new on Arduino programming and I’m stuck with something that makes me crazy. I’m sure one of you would be able to help me. Here is my problem and the associated code :

In the first loop, I’m able to print the 10 first octets of the file. In the second loop, I print always the 11th octet of the file. I think this is because I send a copy of the bmpFile object to the read8 function and that the current position is therefore not changed. I imagine it would be better to use a pointer (or something like this) that could save memory and allow the current position to change following read calls. But I’m unable to write the correct code.

If somebody could help me, I’ll apreciate.

#include <SdFat.h>

#define SD_CS 4        //SD Chipselect
SdFat sd;

void setup(void) {
  sd.begin(SD_CS, SPI_FULL_SPEED); // Initialize SD Card

void loop() {}

void Test(char *filename) {
  SdFile bmpFile;
  int i;, O_READ); // Open requested file on SD card

  for (i=0; i<10; i++) {
  for (i=0; i<10; i++) {
  bmpFile.close(); // Close File object

uint8_t read8(SdFile f) {

uint8_t read8(SdFile *fp) {
  return fp->read();


It works great. Thanks for your help. Best regards.