0
why my code is showing segmentation fault?
I was writing the code for Given sum subarray from geeksforgeeks but in Visual Studio code it was running fine but in geeksforgeeks IDE it is showing segmentation fault. code was subarray. https://code.sololearn.com/cD6iR829pt88/?ref=app
4 odpowiedzi
+ 2
@martin Taylor okay martin i have updated the code please have a look
+ 1
Hi Abhishek Dimri
If you are at beginner level, I would suggest this problem is not for you ....
Try implementing solutions on your own for small easy problem and gradually switch to a tougher problem.. this way only you can learn rather than asking someone to fix the issue. Top most skill is yo have strong debug at last level.
However , as you have already started and ask , your code fails for below input which is documented input.
1
5 12
2 3 4 5 7
Simple thing I did... I just evaluated whether input is acquired in variable properly or not.... I found that sc variable which should hold input array (that is 2 3 4 5 7 in this case) is empty string...
I would suggest not to use cin >> and getline together...
You can do cin>> for all input may be in loop rather than storing in string and then splitting...
Now atleast give a try till this much code on your own and I assume that you would be able to go till this.
0
Martin Taylor i have used the header file <bits/stdc++.h>
0
Martin Taylor actually martin i am new to programming so that's why i am unaware of these conventions so i am really sorry for that, can you please try to understand what i am trying to do in my code and debug it and find the error that i did in this code.