From 84575da5b87f99e488493a9e02f044ddb0390597 Mon Sep 17 00:00:00 2001 From: Guoyi Zhang Date: Fri, 5 Jul 2024 13:03:05 +1000 Subject: [PATCH] fix: use vector to fix the variable int arr --- sortdiamond.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sortdiamond.cpp b/sortdiamond.cpp index fdb35e3..dae4c1f 100644 --- a/sortdiamond.cpp +++ b/sortdiamond.cpp @@ -81,7 +81,8 @@ void readInputFile(const string &filename, string line; while (getline(infile, line)) { istringstream iss(line); - string fields[intmax + 1]; + vector fields(intmax + 1); + // string fields[intmax + 1]; int i = 0; while (iss >> fields[i] && i < (intmax + 1)) { i++; @@ -110,7 +111,8 @@ void processMap(const map> &max_map, const int intmax) { for (const auto &entry : max_map) { istringstream iss(entry.second.second); - string fields[intmax + 1]; + vector fields(intmax + 1); + // string fields[intmax + 1]; int i = 0; while (iss >> fields[i] && i < (intmax + 1)) { i++;