G_P_H_M
03-25-2006, 05:25 AM
Good morning!
I have a problem with open a script file.
I have a directory named hello and it consists of 1 file jobs.sh.
I do :
if((dirp = opendir(/home/user/hello))) { //open the directory
while((dp = readdir(dirp))) {
printf("%s\n",dp->d_name);
if( (fptr = fopen("dp->d_name","r")) != NULL) {
printf("File opened\n");
} else {
printf("File couldn't be opened\n");
}
}
The pink printf outputs :
.
..
jobs.sh
Also,jobs.sh doesn't open,but why?
.
File couldn't be opened
..
File couldn't be opened
jobs.sh
File couldn't be opened
My problem is that the file jobs.sh shall open in order to read it.
Thanks,in advance!
I have a problem with open a script file.
I have a directory named hello and it consists of 1 file jobs.sh.
I do :
if((dirp = opendir(/home/user/hello))) { //open the directory
while((dp = readdir(dirp))) {
printf("%s\n",dp->d_name);
if( (fptr = fopen("dp->d_name","r")) != NULL) {
printf("File opened\n");
} else {
printf("File couldn't be opened\n");
}
}
The pink printf outputs :
.
..
jobs.sh
Also,jobs.sh doesn't open,but why?
.
File couldn't be opened
..
File couldn't be opened
jobs.sh
File couldn't be opened
My problem is that the file jobs.sh shall open in order to read it.
Thanks,in advance!