FAQ Database Discussion Community

C Segfault in readdir after chdir

I am having a weird issue with this C program I'm writing to loop through a directory and open each file to do some work on. My program is located in the parent directory of the directory I'm searching through. In order for fopen to be able to see the...

Using chdir() Causes Segmentation Fault

I'm writing a batch emulator as a personal project. I'm trying to implement the cd command using chdir() from unistd.h. However, using this causes a segfault. main.cpp: #include <cstdlib> #include <iostream> #include <string> #include <vector> #include <stdio.h> //Custom headers #include "splitting_algorithm.hpp" #include "lowercase.hpp" #include "chdir.hpp" //Used to get and print...

fgets and chdir acting strangely together in C

I am currently creating a simple shell for homework and I've run into a problem. Here is a snippet of code with the pieces that pertain to the problem (I may have forgotten some pieces please tell me if you see anything missing): eatWrd returns the first word from a...