mercredi 4 septembre 2019

Windows prompt hangs instead of giving Segmentation Fault

While competitive programming with C++ on Windows using a MinGW compiler, I noticed that my command prompt does not give segmentation faults but instead hangs/ refuses to print output until I hit a Ctrl-C.

I've tried checking if others have had the same problem, but most such problems were with regards to finding the segmentation fault rather fixing the "no error production" in Windows.As one can guess errors are important for competitive coding and I'd like it if I can get my Windows to give me errors, instead of switching to linux for competitive coding.

To reiterate I'm looking to get the prompt to give me a Segmentation Fault(core dumped) like a linux terminal does, instead of hanging/ behaving like an infinite loop or giving any other non seg fault behaviour.

Just to illustrate this code hangs when I input 1000 or 10000. When I input 1000000 it behaved like an infinite loop and printed some junk value over and over again.

#include <bits/stdc++.h>
using namespace std;

#define l long long
#define ii pair<int, int>
#define ll pair<l, l>
#define vii vector<ii>
#define vll vector<ll>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<l>
#define vvl vector<vl>
#define vvi vector<vi>

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    l t; cin >> t;
    l a[13] = {};
    for(int i = 0; i < t; i ++)
    {
        cout << a[t] << endl;
    }
    return 0;
}


Aucun commentaire:

Enregistrer un commentaire