1

Anyone know how to use the seek() function of Arduino SD Library to position pointer at the end of a file?

If programming in Windows do something like:

void fileInsert(char *file, void *data, size_t len) {

    FILE *filePtr;

    if ((filePtr = fopen(file, "rb+")) == NULL) {
        printf("Arquivo %s não pode ser aberto.", file);
        exit(EPERM);

    } else {

        fseek(filePtr, 0L, SEEK_END);
        fwrite(data, len, 1, filePtr);
        fclose(filePtr);
    }
}

But the Arduino does not have the SEEK_END

2

You can only seek to an absolute position from the start of the file. Fortunately there is the size() method that can tell you where the end is, though.

file.seek(file.size());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.