# ATMega32, PetitFS, writing measurements to file

I'm trying to write measurements from external sensor to the file (lets say 1 per second). I'm using ATMega32 and PetitFS. At this moment I'm able to write one measure:

int main(void){

BYTE result;
WORD s1;

for(;;){
sprintf(buff, "Measure: %d\r\n", mes);
s1=4;
result = pf_write(buff, sizeof(buff), &s1);
write_close();
}
}


Now I'm trying to extend above code with pf_lseek to append another measure after previous one. Can someone give me a hint/suggestion how to achieve this?

I think you did not post the whole code, as pf_mount and pf_open are also needed to get started.
First of all - just don't close the file, call pf_write again with another sample.
Second - if you want to append to an existing file - open the file with pf_open and then try pf_lseek perhaps with a very high number (UINT32_MAX). I think that it will just set the pointer to the end of the file (check the error code).