I have some doubts regarding the use of fstat(). The function signature described in ..\VC98\Include\Sys\stat.h is
_CRTIMP int __cdecl fstat(int, struct stat *);
The confusion is that in my c++ program if I pass a local (stack) variable declared as
struct stat st;
int result = fstat(fd,&st);
it compiles.
1. But if I try allocating from the heap using
struct stat *st = new stat;
I get a compilation error error C2061: syntax error : identifier 'stat'
What is happening here ?
2. why is the struct keyword necessary here ? If I remove the struct keyword and just use
stat st;
int result = fstat(fd,&st);
I get the error error C2146: syntax error : missing ';' before identifier 'st'
3. Could somebody explain what the signature
_CRTIMP int __cdecl fstat(int, struct stat *);
means. Specifically how will I know from this signature that the 2nd parameter I pass should be
on the stack or the heap ? And also whether I need to delete this if it is on the heap ?
_CRTIMP int __cdecl fstat(int, struct stat *);
The confusion is that in my c++ program if I pass a local (stack) variable declared as
struct stat st;
int result = fstat(fd,&st);
it compiles.
1. But if I try allocating from the heap using
struct stat *st = new stat;
I get a compilation error error C2061: syntax error : identifier 'stat'
What is happening here ?
2. why is the struct keyword necessary here ? If I remove the struct keyword and just use
stat st;
int result = fstat(fd,&st);
I get the error error C2146: syntax error : missing ';' before identifier 'st'
3. Could somebody explain what the signature
_CRTIMP int __cdecl fstat(int, struct stat *);
means. Specifically how will I know from this signature that the 2nd parameter I pass should be
on the stack or the heap ? And also whether I need to delete this if it is on the heap ?