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?
-
1arduino.cc/reference/en/libraries/sd/seekJuraj– Juraj ♦2023年07月27日 08:12:33 +00:00Commented Jul 27, 2023 at 8:12
-
2Just try it and see what happens. That will be way faster than asking.Delta_G– Delta_G2023年07月27日 15:17:40 +00:00Commented Jul 27, 2023 at 15:17
-
It can be faster to look up the documentation than wait hours for someone to answer.Nick Gammon– Nick Gammon ♦2023年07月28日 01:29:09 +00:00Commented 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.the busybee– the busybee2023年07月28日 06:18:29 +00:00Commented Jul 28, 2023 at 6:18
1 Answer 1
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.