0
typedef struct book {
char title[20];
 char author[20];
 int pages[10];

} Book;

Book b1 = {"The Zahir","Paulo Coelho",336,0};

while writing this structure into SPIFFS of ESP8266, I am using function

filename.write( (const uint8_t*)&b1, sizeof(b1));

but how can write a single data like name of book into structure of spiffs?

0

1 Answer 1

1

For this kind of situation it's best to treat your data as records in a database. To change one part of a record you read the entire record, change the value, then write that record back.

int record = 4; // which record you want to change

struct book b; // Temporary storage for editing the data

// Go to the record and read it in
filename.seek(record * sizeof(struct book));
filename.read( (const uint8_t*)&b, sizeof(struct book));

// Change the data
strcpy(b.title, "Winnie The Pooh");

// Go to the record again and write it out
filename.seek(record * sizeof(struct book));
filename.write( (const uint8_t*)&b, sizeof(struct book));
0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.