B
Bangalore
Hi all,
I was trying out the following program, I want to copy the content of
struct x
variable to file. Here using write of fwrite(used with FILE *fl) I am
not able to
write integer part to the file.
Is there any to copy all contents of structure to file?
struct x{
char a[10];
int t;
}z={"String",10};
int main()
{
int fd;
char buff[100];
if( fd=open("/root/users/PRI/text",2|O_CREAT,0766))<0)
printf("Error in getting fd \n");
else
write(fd,&z,sizeof(z));
read(fd,buff,100);
printf("The content is = %s \n",buff);
}
Thanks,
Bangalore
I was trying out the following program, I want to copy the content of
struct x
variable to file. Here using write of fwrite(used with FILE *fl) I am
not able to
write integer part to the file.
Is there any to copy all contents of structure to file?
struct x{
char a[10];
int t;
}z={"String",10};
int main()
{
int fd;
char buff[100];
if( fd=open("/root/users/PRI/text",2|O_CREAT,0766))<0)
printf("Error in getting fd \n");
else
write(fd,&z,sizeof(z));
read(fd,buff,100);
printf("The content is = %s \n",buff);
}
Thanks,
Bangalore