int main ( int argc, char * argv[] ){
HANDLE fh;
OFSTRUCT o_s;
register char * a;
unsigned long int i1;
for (a= &o_s; a < (&o_s + sizeof(o_s)); a++) *a= 0;
fh= OpenFile ( "C:/test.txt", &o_s, OF_READWRITE );
WriteFile ( fh, "file_io.c was here", sizeof ("file_io.c was here"), &i1, NULL );
CloseHandle ( fh );
return sizeof ("file_io.c was here") - i1;
}
But the compiler keeps complaining about types: C:\Users\Administrator\Desktop>\dm\bin\dmc -I\dm\stlport\stlport file_io.c for (a= &o_s; a < (&o_s + sizeof(o_s)); a++) *a= 0; ^ file_io.c(27) : Error: need explicit cast to convert from: struct _OFSTRUCT* to : char * fh= OpenFile ( "C:/test.txt", &o_s, OF_READWRITE ); ^ file_io.c(28) : Error: need explicit cast to convert from: int __import to : void * --- errorlevel 1
I tried changing the code to this:
int main ( int argc, char * argv[] ){
HANDLE fh;
OFSTRUCT o_s;
register char * a;
unsigned long int i1;
for (a= &[COLOR="red"](char *)[/COLOR]o_s; a < (&o_s + sizeof(o_s)); a++) *a= 0;
fh= OpenFile ( "C:/test.txt", &o_s, OF_READWRITE );
WriteFile ( fh, "file_io.c was here", sizeof ("file_io.c was here"), &i1, NULL );
CloseHandle ( fh );
return sizeof ("file_io.c was here") - i1;
}
But now the compiler tells me: C:\Users\Administrator\Desktop>\dm\bin\dmc -I\dm\stlport\stlport file_io.c for (a= &(char *)o_s; a < (&o_s + sizeof(o_s)); a++) *a= 0; ^ file_io.c(27) : Error: illegal cast from: struct _OFSTRUCT to : char * fh= OpenFile ( "C:/test.txt", &o_s, OF_READWRITE ); ^ file_io.c(28) : Error: need explicit cast to convert from: int __import to : void * --- errorlevel 1
I don't know if there is anything else wrong with the code, though, besides the syntax.
But I don't know what the compiler means; can anyone tell me how to fix the code?


Sign In
Create Account


Back to top









