CB100

Notas, resueltos y tps de la materia Algoritmos y Estructuras de Datos
Index Commits Files Refs README
commit 5ff8ff5995be3c9221f290c1a7af51f829640a17
parent 4c71d42fbc0a66e1c5242593b83839f4b98ae4f9
Author: Martin Kloeckner <mjkloeckner@gmail.com>
Date:   Mon, 17 Jun 2024 20:00:35 -0300

fix reading a token which is a string and contains INPUT_FILE_DELIM

previously the token was treated as diferent tokens, for example the
token `"Hello, World"` was treated as two different tokens: `"Hello` and
`World"` now all the characters in between double quotes `"` are treated
as the same token

Diffstat:
Mmain.cpp | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/main.cpp b/main.cpp
@@ -26,6 +26,11 @@ int main (void) {
     while(std::getline(inputFile, line)) {
         lineStream.str(line);
         while(std::getline(lineStream, token, INPUT_FILE_DELIM)) {
+            while((token[0] == '"') && (token[token.size() - 1] != '"')) {
+                std::string nextToken;
+                std::getline(lineStream, nextToken, INPUT_FILE_DELIM);
+                token += INPUT_FILE_DELIM + nextToken;
+            }
             tokens.insert(token);
         }
         lineStream.clear();