avoid sprintf() through C++ features and libfmt

This commit is contained in:
Axel Kohlmeyer
2023-01-07 15:47:46 -05:00
parent 1556460b8f
commit d572d8f051
3 changed files with 10 additions and 17 deletions

View File

@ -2437,13 +2437,13 @@ void ReadData::parse_coeffs(char *line, const char *addstr, int dupflag, int nof
if (noffset) {
int value = utils::inumeric(FLERR, coeffarg[0], false, lmp);
if (labelmode) value = ilabel[value - 1];
sprintf(argoffset1, "%d", value + offset);
coeffarg[0] = argoffset1;
argoffset1 = std::to_string(value + offset);
coeffarg[0] = (char *)argoffset1.c_str();
if (noffset == 2) {
value = utils::inumeric(FLERR, coeffarg[1], false, lmp);
if (labelmode) value = ilabel[value - 1];
sprintf(argoffset2, "%d", value + offset);
coeffarg[1] = argoffset2;
argoffset2 = std::to_string(value + offset);
coeffarg[1] = (char *)argoffset2.c_str();
}
}
}