von printf nach cout
-
printf("%0*d\t%*d\t %*llu\t %*d\t", 3, i, 4, x, 7, (GetTime() - start_time) / 10, 20, nodes);
Wie setzt man das möglichst einfach in std::cout usw. um?
Lohnt sich das hier überhaupt, oder lasst ihr so etwas im alten C-Style?
-
Entweder machst Du Dir die Mühe das iostream zu portieren, oder Du nimmst eine der printf like type safe Lösungen für C++ (z.B. boost). Damit sind dann typische Formatstringprobleme von C Geschichte.
-
Nimm https://github.com/fmtlib/fmt oder C++20 (https://en.cppreference.com/w/cpp/utility/format), wenn verfügbar.
-
Ich arbeite mit VS 2019
-
@Erhard-Henkes sagte in von printf nach cout:
Ich arbeite mit VS 2019
Wunderbar, dann kannst du die fmtlib ja benutzen.