am trying to run mu program but i got the following error message
"terminate called after throwing an instance of 'std::length_error'
what(): basic_string::_S_create"
I understand that this might be issue with the memory and maybe is where i need to make a change but i still cant find the issue. Can someone help me pls?
main.cpp
using namespace std;
ifstream input;
ofstream output;
int Registers[32] = {};
int Cycle = 0;
//print details which change
void print_memory(int t[], int a[], int m)
{
output << endl << "Memory State:" << endl;
for (int i = 0; i < m; i++)
{
output << "[" << a[i] << "]: " << t[i] << endl;
}
}
int find(int arr[], int SIZE, int values) {
for (int a = 0; a < 40000; a++)
{
if (arr[a] == values)
{
return a;
}
}
}
//find register position
int table(string x) {
int i = 0;
if (x == "zero" || x == "zero " || x == " zero" || x == " zero ")
{
i = 0;
}
else if (x == "at" || x == "at " || x == " at" || x == " at ")
{
i = 1;
}
else if (x == "v0" || x == "v0 " || x == " v0" || x == " v0 ") {
i = 2;
}
else if (x == "v1" || x == "v1 " || x == " v1" || x == " v1 ")
{
i = 3;
}
..
}
else if (x == "ra" || x == "ra " || x == " ra" || x == " ra ")
{
i = 31;
}
return i;
}
void printtofile(string k) {
output << k;
}
void print_cycle(int x) {
output << "-Cycle N" << x << "-" << endl;
}
int main() {
int address[40000] = {};
int timi[40000] = {};
Registers[28] = 268468224;
Registers[29] = 2147483644;
//sam var
int ee = 0;
int aa = 0;
int kk = 0;
int kkk = 0;
int pccounter = 0;
//-INPUT CYCLES FROM THE USER AND PRINT MESSAGES-
I can't compile your code, even after several minutes of fixing syntax errors and creating dummy structures for the ones you haven't defined. Please post code something that will compile.
am trying to run mu program but i got the following error message
"terminate called after throwing an instance of 'std::length_error'
what(): basic_string::_S_create"
Did you run the program with your debugger? The debugger should be able to tell you exactly where it detected the problem, and you should be able to view the contents of the variables at the time of the crash.
Edit:
i cant put the whole code because its too big, is there any way i can show you what i have done?
Then post the smallest possible complete program that illustrates the problem.