G
GeeRay
Hi all,
I was reading a code of a software which write some data in a log
file. This software was written by another programmer and I need to
update some parts. Every time the previous programmer needed to append
some data to an output file he did like this:
ofstream outfile;
ostringstream ostr;
ostr << "outfile.log";
char* log_name = const_cast<char*>(ostr.str().c_str());
outfile.open(log_name, ios:
ut | ios::app);
but I always do like this:
ofstream outfile;
outfile.open("outfile.log", ios:
ut | ios::app);
What are the differences?
The previous programmer is supposed to have more experience in C++ and I
don't understand why he write such a piece of code to open a file.
Thanks.
I was reading a code of a software which write some data in a log
file. This software was written by another programmer and I need to
update some parts. Every time the previous programmer needed to append
some data to an output file he did like this:
ofstream outfile;
ostringstream ostr;
ostr << "outfile.log";
char* log_name = const_cast<char*>(ostr.str().c_str());
outfile.open(log_name, ios:
but I always do like this:
ofstream outfile;
outfile.open("outfile.log", ios:
What are the differences?
The previous programmer is supposed to have more experience in C++ and I
don't understand why he write such a piece of code to open a file.
Thanks.