简体   繁体   中英

This program stops working while execution . i made this program in codeblocks

Why does this program stops working with a message which says process returned -1073741819 on codeblocks ? All other programs are working on code blocks except for this one. This is my uncompleted project for my college assingment.

    #include<iostream>
    #include<vector>
    #include<math.h>
    #include<cstdlib>
    using namespace std;
    int main()
    {
        cout<<"\tThis is a C++ program to implement Quine-McCluskey logic to minimize a given Boolean function"<<endl;
        unsigned int nv,nmin,roll,i;
        vector<int> minterms;
        cout<<"Enter your roll number    ";
        cin>>roll;
        srand(roll);
        cout<<endl<<"Enter the number of variables(1-10)";
        cin>>nv;
        if(nv<1||nv>10)
        {
            cout<<endl<<"Invalid number of variables";
            exit(0);
        }
        cout<<endl<<"Enter the number of min-terms(1-"<<pow(2,nv)<<")   ";
        cin>>nmin;
        if(nmin<1||nmin>pow(2,nv))
        {
            cout<<"Invalid number of min-terms(1-"<<pow(2,nv)<<")";
            exit(0);
        }/*it stops here*/
        for(i=0;i<nmin;i++)
        {
            minterms[i]=rand()%int(pow(2,nv));
        }
        cout<<endl<<"The randomly generated min-terms are ";
        for(i=0;i<nmin;i++)
        {
            cout<<minterms[i]<<"  ";
        }

    }

You're not allocating any space in the minterms vector. Instead of assigning to minterms[i] , pass the values to minterms.push_back() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM