Segmentation fault in the code to reverse an array
#include <bits/stdc++.h> using namespace std; int main(){ int n,i,j; int arr[n]; cin>>n; for (j = 0; j < n; j++) { cin >> arr[j]; } for (i = n+1; i >=0; i–) { cout << arr[i] << ” “; } } for most of the test cases it is showing segmentation fault for the given […]
Seg fault for c++ program
Whenever I try to enter the name of the description of a movie, or anything else related to a string entry, it always seg faults. I can enter the name and genre of a movie fine.
How to solve segmentation fault here and where it appears?
I’m making terminal game of life and when glider figure goes out of the map segfault 11 appears. Could you tell me where particularly this segfault appears and how to solve it?
C++ segmentation fault on std::cout
I’ve written some C++ code that works completely fine in WSL (also valgrind showed no free / delete mismatches and also no leaked memory), but the same program compiled in CygWin leads to segmentation fault at the first line of code in main()
:
I found a error “Exception has occurred. Unknown signal” when debug my Quicksort code made by myself. What is this error?
`#include <iostream> #include <cmath> using namespace std; void quicksort(int *n, int length){ if(length > 1){ int *left, *right; int leftLength = 0, rightLength = 0; for(int i = 0; i < length; i++){ if(n[i] <= n[length – 1]){ int *tmp = left; leftLength++; left = new int[leftLength]; for(int j = 0; j < leftLength – […]