1

I have in my code in c, this function:

 fseek(file, 0, SEEK_SET);

I need to use the same function with Arduino ide. Is this correct?

 file.seek(file.size());

Or what is the alternative function in Arduino ide?

Rohit Gupta
6122 gold badges5 silver badges18 bronze badges
asked Jul 27, 2023 at 8:05
4
  • 1
    arduino.cc/reference/en/libraries/sd/seek Commented Jul 27, 2023 at 8:12
  • 2
    Just try it and see what happens. That will be way faster than asking. Commented Jul 27, 2023 at 15:17
  • It can be faster to look up the documentation than wait hours for someone to answer. Commented Jul 28, 2023 at 1:29
  • OT, to clarify technical terms: The Arduino IDE is just that, an integrated development environment. It does not provide functions or classes, it just recognizes the names and therefore give you some support. The real thing you mean are the Arduino libraries, the reference of which you should bookmark in your browser. However, an installation puts all of this on your computer. (There is more, for example the compiler system...) You can use each without the other. Commented Jul 28, 2023 at 6:18

1 Answer 1

2

According to https://www.arduino.cc/reference/en/libraries/sd/seek/ :

SD - seek()

Seek to a new position in the file, which must be between 0 and the size of the file (inclusive).

Syntax

file.seek(pos)

Parameters

  • file: an instance of the File class (returned by SD.open()).
  • pos: the position to which to seek (unsigned long).

If you want to seek to the start of the file, therefore you should seek to zero, not file.size(). Using file.size() would seek to the end of the file.

answered Jul 28, 2023 at 1:29

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.