Hi Guys,
I am new to this set-up and started to have problems while compiling the program. This is the snapshot of my code:
#include <fstream>
void setup() {
std::fstream file;
file.open("abc.txt", std::ios::out | std::fstream::app);
if(!file.is_open()) {
Serial.println("ERROR1: FILE NOT OPENED.");
}
}
There is nothing inside loop function. it is empty.
Problem is that for some reason, I see this message:
ERROR1: FILE NOT OPENED.
I would like to understand why. There are no issues during the compilation as well. I would be happy to write more if needed.
gcjr
2
does "abc.txt" exist?
does is need to be "created"?
blh64
3
It does not exists. It needs to be created new. I think the probable reason could be of non-availability of the file system on my(esp) processor.
Thanks for the pointer man. Cheers!
gcjr
6
"open" typically fails if the file doesn't exist. there's probably a CREATE option, for when a file is written to for the first time
I tend to use append instead of open for file creation. With append if the file does not exist then create it and then open it for append.
Hi gcjr,
Thanks for the reply.
Open does not mean that it is opening in read mode. It can also open in write mode as well, depending on the options you pass.
Thanks Idahowalker. I think the reason is the non-availability of the file system at the esp processor system.
gcjr
10
and those options include create/append for when a file may not exist
system
Closed
11
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.