I am trying open dir and read files inside it .
but the function opendir() returns always "No such file or directory", and when I put the the path it's working .
Working:
if (!(dir = opendir("/home/user/workspace/OS-Ex2Files/students/"))){
perror(dir);
return;
}
Not working:
printf(dirPath); // prints /home/user/workspace/OS-Ex2Files/students/
if (!(dir = opendir(dirPath))){
perror(dir);
return;
}
dirPath is a char* .
Can you please explain me why the second option is not working?