Click here to Skip to main content
15,559,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i keep getting Process returned -1073741819 (0xC0000005) whenever I run this code, what's the reason?

#include <cmath>
    #include <stack>
    #include <iostream>
    #include <regex>
     #include <vector>
    #include <thread>
     #include <bitset>
     #include <ctime>
     #include <string.h>
     #include <math.h>
    #include <bits/stdc++.h>
     #define M_PI 3.14159265358979323846264338327950288419716939937510582097494
    #define gkey GetAsyncKeyState
     using namespace std;
    #define rxs regex_search
    #define loop while(true)
    double a;
    double num1;
     double c3 = 299792458;
     double c3sq = 89875517873681764;
     int mc;
         string again;
     stack<int> presedence;
     stack<string> oprators;
     queue<double> numbers;
     stack<char> test;
     double num5;
     double num6;
     int E;
     int abrt = 0;
     double num2;
     double ans = num1 + num2;
     int num;
     int numalt = 0;
     int numaltt = 0;
     //int nums [] = {srand(time(0));rand();}
    bool autoregex(string test){
        regex e ("[-+]?([0-9]*\.[0-9]+|[0-9]+)");
       if (regex_match (test,e))
            return true;
        return false;
    bool autrege(string test){
        regex aret("SIN|LOG|sqrt|sin|log|tan|pi|e|ln|EE|[^0-9a-z$@#&\]");
                   if (regex_match (test,aret)){
                    return true;
        return false;}
                   void namehere(string test){
    if(autrege(test) == true){
    regex bret("[+-]");
    regex cret("[/*xX]");
    regex dret("SIN|LOG|sqrt|sin|log|tan|pi|!|e|ln|EE|\\^");
    regex omega("\\)");
    regex canmae("\\(");
    if (regex_match (test,bret)){num2 = 1;};
    if (regex_match (test,cret)){num2 = 2;};
    if (regex_match (test,dret)){num2 = 3;};
    if (regex_match (test,omega)){num2 = 4;numaltt = numaltt + 1;};
    if (regex_match (test,canmae)){num2 = 4;numalt = numalt + 1;};
    int main()
    vector<double> vec;
        again = "n";
     while(again == "n"&&abrt == 0){
     // queue<double> numbers; stack<int> pres;
            queue<string> output;
       int test;
     string name;
       getline(cin, name);
       istringstream iss(name);
     string token;
        while(iss >> token)
          if(autoregex(token) == true){
          if(autrege(token)== true)//token area
              if(num2 == -1){cout<<"wrong move: ";again = "n";again = "y";cout<<num2<<endl;}
           while(presedence.empty() == 1 && oprators.empty() == 1)
           while( < num2)
           while( >= num2)
    //3-T 2-ME
    while(presedence.empty() != 1 && oprators.empty() != 1){  output.push(;
    while(!output.empty()){cout<<output.front()<<", ";output.pop();}
    while(again != "n"&&abrt == 0){

What I have tried:

I've tried changing the revamping the entire code to include an error case, tried checking if the stack was empty before popping, didn't work still, I tried removing the precedence system, didn't work, I've got no ideas on what to do now, found the issue the code breaks when I try to see if Is = to the current precedence, any reasons why?
Updated 23-Dec-21 12:16pm

0xc0000005 is the Windows error code for an invalid memory access (SIGSEGV), so it may not simply be a matter of adding a return 0 to your code. Although the standard says that main is supposed to return an int, Microsoft's C/C++ compiler does not enforce this. Your program could actually be crashing, perhaps after it has done what you expect. Set a breakpoint at the return 0 and see if the code actually reaches that point.
Share this answer
If your code doesn't return a value to the system, it gets a random number - and since a return value of zero is "OK exit" and any other value is an error code you always get an error from your app because you aren't returning anything specific.
So as steveb has said: add
return 0;
To the end of your app and the problem will go away.

But do yourself a favour and indent your code properly - that's a mess and it makes it much harder to read and maintain (or even fix) than it should be. You may understand it now, but in three weeks it'll be gobbledegook to you as well ...
Share this answer
k5054 23-Dec-21 7:05am    
I think the OP must some have other problem that he should examine. C++ will add a return 0 if no other return value from main is specified. If the OP's code is returning some other value, and main() does not have a return statement, then something is wrong. Unfortunately, the OP's code does not compile, even allowing for missing #includes. There are various variables that are accessed but not defined, and there's no closing brace for main(), so there's no knowing what the code might be doing in the missing sections.
your main declared as
int main()
but you do not return any values. Add
return 0;
Share this answer
Abdulrahmon Tijani 23-Dec-21 17:09pm    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900