My question about using functions with struct
. I took the snippet from R.Stevens' book and I saw similar snippets a couple of time. I suggest to get some C and Linux experience, but I really do not know how to use struct in right way in this case.
struct stat buf; // The error line
for (i=1; i < argc; i++){
if (lstat(argv[i], &buf) < 0) { // Usage of
err_ret("lstat error");
continue;
}
if (S_ISERG(buf.st_mode))
ptr = "regular";
When I compile my code I have got an error:
type.c: In function ‘main’:
type.c:9:15: error: storage size of ‘buf’ isn’t known
What is wrong with the struct declaration? Should I explicitly declare struct size? If it is, how do I know it? And the main question - how is it works struct method name
?
You forgot to include:
#include <sys/types.h>
#include <sys/stat.h>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With