Im trying to write an interpreter on c++ that will be used in wombat 1.
I got this error on my program when complied: std::out of range
what():basic_string::substr
1 2
opcode[line_array] = file.substr(0,4);// Reads the opcode
operand[line_array] = file.substr(4,12);// Reads the operand
inFile.open ("E:\\file.txt", ios::in);
int r = 0;
if (inFile.fail())
{
cout <<"File could not be read"<<endl;
}
else
{
while (!inFile.eof())//
{
getline(inFile,file);
opcode[line_array] = file.substr(0,4);// Reads the opcode
operand[line_array] = file.substr(4,12);// Reads the operand
line_array++;
}