Relative Content

Tag Archive for csegmentation-fault

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.

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():