Skip to content
Advertisement

Tag: chdir

C Corrupted double-linked list after calling chdir

I’ve been working on some C code to provide functionality similar to the shell. So far it can run most commands like cat, ls, ls | grep …, etc. After writing code to implement the functions “cd”, “pwd”, “pushd” and “popd”, I have been testing it. If I write “cd ..” or “cd anydir” it will run “chdir(anydir)” and return

C — using chdir() function

I’m trying to use chdir() function but can’t work it out. I’m reading from user and find out if he is using “cd”. I always get an error. What am I doing wrong? Code: Answer If the line being entered is something like: then the directory starts at offset 3, not 2. In addition, fgets usually gives you a line

Advertisement