#include <SD.h>
#define SD_CS 4
void setup() {
File testFile;
char strA[] = {"aaaaaaaaaaaaaaaaaaa"};
char strB[] = {"bbbbb"};
char buff[25];
Serial.begin(9600);
if (SD.begin(SD_CS)) {
testFile = SD.open("/testFile", FILE_WRITE);
if (testFile) {
testFile.write(strA,20);
testFile.close();
testFile = SD.open("/testFile", FILE_READ);
testFile.read(buff,20);
buff[20] = '\0';
Serial.println(buff);
testFile.close();
testFile = SD.open("/testFile", O_WRITE); // Open for write and NOT append..
if (testFile.seek(5)) { // <<== seek() to 5..
testFile.write(strB,5);
testFile.close();
testFile = SD.open("/testFile", FILE_READ);
testFile.read(buff,20);
buff[20] = '\0';
Serial.println(buff);
} else {
Serial.println("seek() failed.");
}
}
}
}
void loop() { }