Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Process exited with value 3221225477

Status
Not open for further replies.

michaelScott

Junior Member level 2
Joined
Mar 19, 2022
Messages
24
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
161
Hello friends,

I am currently working on a homework. But the code i wrote is not works as expected what i mean is that when i run the code sometimes i get the following error and integer values get unreasonable values.
"Process exited with value 3221225477"
Where do i do wrong.

Can you help me. Thanks in advance
C++:
#include <stdio.h>
#include <stdlib.h>
#include <queue>
#include <cstdlib>  //contains prototypes for functions srand and rand
using std::srand;
using std::rand;
#include <ctime>    //contains prototypes for function time
using std::time;
using namespace std;
#define N 30
#define MIN_SD 1
#define MAX_SD 5

struct Customer_Info {
    int customer_number;
    int arrive_time;
    int service_duration;
};
struct Customer_Info CustomerInfo;

int main() {
    int customernumber = 0;
    queue<Customer_Info> Q;
    srand(time(NULL));
    printf("SIMULATION LOOP STARTED\n\n");
    for (int currentTime = 0; currentTime <= N; currentTime++) {
        //with 0.5 random probability
        int p = rand() % 2;
        if (p) { //If there is customer arrival
            CustomerInfo.customer_number = ++customernumber;
            CustomerInfo.service_duration = (rand()%MAX_SD) + MIN_SD;
            CustomerInfo.arrive_time = currentTime;
            printf("TIME:%02d Customer %d arrived.\n", currentTime, CustomerInfo.customer_number);
            Q.push(CustomerInfo); // Add (enqueue) structure to queue
        }
        //Check the front element of Queue to determine whether the front element is eligible to remove from Queue.
        if (Q.front().arrive_time + Q.front().service_duration <= currentTime) {
            printf("TIME:%02d Customer %d departed. Service duration:%d\n", currentTime, Q.front().customer_number, Q.front().service_duration);
            Q.pop();
        }
    }
    printf("\nSIMULATION LOOP FINISHED.");
    printf("\n\nREMOVING REST OF THE CUSTOMERS FROM QUEUE.\n");
    while (!Q.empty()) {
        printf("TIME: %2d Customer %2d departed. Service duration: %d\n", (Q.front().arrive_time + Q.front().service_duration), Q.front().customer_number, Q.front().service_duration);
        Q.pop();
    }
    //system("pause");
    return 0;
}
 

Since the above snippet is quite small, and due it already contains some printf() outputs, I would add more of them populating between each instruction line in order to determine the exact point that lead to the system failure, in addition, you could even display values of variables on these printf()'s; BTW, the decimal integer 3221225477 means C000 0005 in hexadecimal, so one could guess the effective error code is actually '5'.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top