I need to use the built-in struct stat.
How can I get the information of a file into a stat structure?
Thanks in advance,
DarkRoom
I need to use the built-in struct stat.
How can I get the information of a file into a stat structure?
Thanks in advance,
DarkRoom
There is no build-in struct stat
It depends on your OS, so if you're trying this on windows, then you're out of luck.
Tell us what you're trying to do, and the OS/Compiler you're using.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Sorry, I wasn't explicit. I am using ubuntu. Compiler gcc
I want to use the structure stat defined in sys/stat.h to gather file information.
OK, that would work.
Have you figured anything out at all? Have you read the manual page for the function?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Ya, i got it. But is am still facing problems to check whether a given file path is that of a directory. Because I need to implement ls -l, I need the permissions and also the information about it being a directory.
So are you not allowed to use S_<whatever> macros for some reason?
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
There is no such thing as a "windows compiler". There are compilers that run in Windows. There are compilers that can produce executables for Windows. But saying "Windows supports the stat() function..." is not accurate.
There is no stat function in the standard C library.
Quzah.
Hope is the first step on the road to disappointment.
Thanks, I didn't know about the S_<macros>.
Searched the internet and got it. Now my code works.