summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2022-04-28 16:09:20 -0500
committerHombreLaser <sebastian-440@live.com>2022-04-28 16:09:20 -0500
commit44ec4d12336e290ad8d1f6e1559e04bf19e79075 (patch)
tree98ec03572ff9cfe211b7691e3bb4c00f43c57530 /main.cpp
parent3fa0be1d2d3408b9fb2adbcf975fa49acd87e50d (diff)
Corregido error de memoria
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/main.cpp b/main.cpp
index 9328b1e..0c20f99 100644
--- a/main.cpp
+++ b/main.cpp
@@ -2,6 +2,7 @@
* FACULTAD DE CIENCIAS FÍSICO MATEMÁTICAS
* Luis Sebastián Martínez Vega - LCC */
+#include <cstddef>
#include <iterator>
#include <ostream>
#include <string>
@@ -16,19 +17,20 @@
using std::string, std::cin, std::cout, std::getline, std::vector,
std::begin, std::end, std::endl;
-int main(){
+int main() {
int counter = 1;
string input;
Parser parser;
- Expression *tree, *simplified, *diff;
+ Expression *tree = NULL, *simplified = NULL, *diff = NULL;
cout << ">> ";
while(getline(cin, input)) {
try {
tree = parser.parse(input);
} catch(const ParserException &e) {
- cout << e.showMsg();
+ cout << e.showMsg() << "\n";
cout << ">> ";
+ tree = NULL;
continue;
}
@@ -40,6 +42,9 @@ int main(){
delete tree;
delete simplified;
delete diff;
+ tree = NULL;
+ simplified = NULL;
+ diff = NULL;
++counter;
}