This seems simple, but I can't get it to work. I'm writing a simple compiler program in VC++ 6. I'm trying to define three strings that will be checked by my parser to make sure they are syntactically correct. The problem is, I'm not sure how to include semicolons and parentheses in a string. The program compiles, but crashes when run.
Here are the three inputs:
Code:
#include <string>
using namespace std;
int main()
{
string input1 = "i+i+i;";
string input2 = "i/n;";
string input3 = "(i*i+i*i+i*i);";
return 0;
}
I've tried escaping the semicolons and parentheses, but the program still crashes.
Code:
string input1 = "i+i+i\;";
string input2 = "i/n\;";
string input3 = "\(i*i+i*i+i*i\)\;";
Thanks for the help!