This avoids the potential for buffer overflows.
* Set the output name template.
*/
void
- file_name_format(const char *);
+ file_name_format(const std::string &format);
/**
* Return the output name template.
*/
- const char *
+ const std::string &
file_name_format();
private:
/**
* Output file name template.
*/
- char format[30];
+ std::string format;
};
inline void
- TimestepControl::file_name_format(const char *fmt)
+ TimestepControl::file_name_format(const std::string &fmt)
{
- strcpy(format, fmt);
+ format = fmt;
}
- inline const char *
+ inline const std::string &
TimestepControl::file_name_format()
{
return format;
, step_val(start_step)
, print_step(print_step)
, next_print_val(print_step > 0. ? start_val + print_step : start_val - 1.)
+ , format("T.%06.3f")
{
now_val = start_val;
- strcpy(format, "T.%06.3f");
// avoid compiler warning
(void)min_step_val;
In the beginning the Universe was created. This has made a lot of
people very angry and has been widely regarded as a bad move.
Douglas Adams