Relative Content

Tag Archive for csegmentation-fault

Simply trying to use opendir() in my program gives me segmentation fault. Im on vscode and in my schools linux sever

#include <stdio.h> #include <stdlib.h> #include <string.h> #include <dirent.h> #include <sys/types.h> #define MAX 100 int copy(char fileName[], char dirName[]) { printf(“0”); //open directory and test if it opens successfully DIR *OGdir = opendir(“~/”); struct dirent *OGdp = readdir(OGdir); if(OGdir == NULL) { printf(“nUnable To Open Directoryn”); return(-1); } printf(“1n”); //more code will go here i have […]

Segmentation fault in C BogoSort

I’ve started learning c and wanted to program bogosort with it. I coded the most parts, but as I started it, I’ve got a segmentation fault error, but don’t know why.

Segmentation fault in my matrix-reading program

I created a program that is supposed to read two 3D matrices from a binary file, multiply them, and print the result to a binary file. However, while it successfully compiles, when I run it, it gives me a segmentation fault error.

What are common reasons for segmentation faultS when using map in C++?

In the project I’ve been coding recently, creating a new map inside a certain function and adding two elements to it causes a segmentation fault. These same lines (which are completely unrelated to the rest of the program), run completely fine in separate projects or online compilers, what could be the reason for the segmentation fault this time? how can lines that have nothing to do with the rest of the program run badly in this case?