samedi 27 juin 2020

Abort signal from abort(3) (SIGABRT) in C++

#include <iostream>
using namespace std;

int main()
{
    //code
    int test;
    cin >> test;
    while(test--)
    {
        int count = 0;
        string input;
        cin >> input;
        for (int j = 0; j < input.length() - 2; j++)
        {
           if (input.substr(j, 3) == "gfg")
           {
                count +=1;
           }
        }
        if (count > 0)
        {
            cout << count << endl;
        }
        else
        {
            cout << -1 << endl;
        }
        
    }
    return 0;
}

This code shows Abort signal from abort(3) (SIGABRT) while submitting in Geeks for Geeks while runs perfectly on the local computer and even works perfectly on various online compilers. Can't figure out the problem. Can someone help?

Aucun commentaire:

Enregistrer un commentaire