fputs(), fputc() appending string/characters twice issue
Posted: Sun Aug 20, 2023 11:03 pm
When opening a file in append mode and start putting a string into file stream then closing the file and opening the file again in read mode it shows the string is written/flushed twice. Example code:
The output result:
I have tried this code on my pc and it works fine just as intended but in ESP-IDF i cannot figure out what is happening. Any help will be much appreciated.
- char *txt = "World";
- FILE *fs_a = fopen("/filesPartitionFatfs/test.txt", "a");
- fputs(txt, fs_a);
- fclose(fs_a);
- FILE *fs = fopen("/filesPartitionFatfs/test.txt", "r");
- do{
- if(feof(fs)){ break; };
- char c = fgetc(fs);
- printf("%c", c);
- }while(1);
- fclose(fs);
Code: Select all
WorldWorld