diff --git a/cpp/QrCodeGeneratorDemo.cpp b/cpp/QrCodeGeneratorDemo.cpp index a2c8cfa..befecb0 100644 --- a/cpp/QrCodeGeneratorDemo.cpp +++ b/cpp/QrCodeGeneratorDemo.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -124,9 +125,7 @@ static void doSegmentDemo() { QrCode::Ecc::LOW); printQr(qr2); - std::vector bytes; - for (const char *temp = golden0; *temp != '\0'; temp++) - bytes.push_back(static_cast(*temp)); + std::vector bytes(golden0, golden0 + std::strlen(golden0)); const QrCode qr3 = QrCode::encodeSegments( {QrSegment::makeBytes(bytes), QrSegment::makeNumeric(golden1), QrSegment::makeAlphanumeric(golden2)}, QrCode::Ecc::LOW); diff --git a/cpp/QrCodeGeneratorWorker.cpp b/cpp/QrCodeGeneratorWorker.cpp index 8ca58dc..2033feb 100644 --- a/cpp/QrCodeGeneratorWorker.cpp +++ b/cpp/QrCodeGeneratorWorker.cpp @@ -75,9 +75,7 @@ int main() { // Make list of segments std::vector segs; if (isAscii) { - std::vector text; - for (std::vector::iterator it = data.begin(); it != data.end(); ++it) - text.push_back((char)*it); + std::vector text(data.cbegin(), data.cend()); text.push_back('\0'); segs = QrSegment::makeSegments(text.data()); } else