After opening a directory, I wanna check if a command (such as ls) resides within a given directory but open returns an integer i think.. after tokenization, I’m left with some directories… so what can i do?? I was told to use only open() function :((
int Account_Master;
. . .
Account_Master = open ("accounts.dat", O_RDONLY);
if (Account_Master >0) {
printf ("Open succeeded.\n");
this is the example i used.. whats the point of opening a file if no use?
The integer returned can be given to other functions, such as
read,fstat, andclose. If you just want to check whether a file exists, usestat:If you don’t want to check a single file, but a whole directory, have a look at
readdirinstead.