Hello !
I am a novice C-programmer, and I am having
trouble with the systemcalls write/open.
Please look at the following source-code :
void main()
{
struct person
{ char name[30];
int age;
float weight;
};
register int fd;
struct person ps;
int rs;
copystr("Mr.Johnson",ps.name);
ps.age=52;
ps.weight=82;
fd=open("file",1);
if(fd==-1)
{
printf("Could not open file\n");
exit(1);
}
rs=write(fd,(char *)ps,sizeof(struct person));
if(rs==-1)
{
printf("Could not write to file\n");
}
(void)close(fd);
}
But, the compiler says :
CAST is not a permitted struct/union operation
Well, what can I do instead of CASTing ??
If you'll answer this I'll be very happy.
If you have a sample-code using fopen,fwrite,
please mail it to me.
Thanks in advance.