Tried but in vain to list contents of a directory
Having learnt directory too is a interpreted as a file , I tried opening it in vi editor and i found its contents(i mean files n sub-dirs) there , maybe , i thought these strings are symbolic links to the actual contents in memory..
Later, when I tried to print same contents using "cat" it gave me an error that the argument is a directory and hence I wrote a simple C code to open the directory argument as a file (it is ofcourse) n list its contents parsing the file character by char. When i compile n run it with some sub-directory as an argument , unfortunately it didn't print anything.
So this time i edited my code such that it prints the no of bytes too in this (directory) file (just seeking the file pointer to the end n printing its offset using ftell()) n when i run it it gives me the fixed integer "4096" for many directories which i have tried (including the / directory), but still no contents(i.e no bytes) being displayed ..
I felt it crazy n something is there in these directory files which i yet donno ,
as the code appears elementary i don't think its necessary posting it here...
just learnt C in UNIX ( all those editing n using cc,gdb,linking libraries , running executables..) , i am a sort of beginner in UNIX ...
hope i am pretty clear with my doubt.. n any solution is greatly appreciated...
Last edited by rs_vijay; 01-17-2007 at 03:54 PM.