Message-ID: <3952C4BE.C9D570E9@cue.satnet.net> Date: Thu, 22 Jun 2000 21:00:30 -0500 From: Ronald =?iso-8859-1?Q?Pati=F1o?= X-Mailer: Mozilla 4.61 [en] (Win95; I) X-Accept-Language: en MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: newbie question:Writing a structure to a file Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Hi, can someone help me with this, can you please point out what my mistakes are. Im trying to write this structure to a file, and then retrive it from another program, but i'm having troubles. struct db{ char *url; char test; }; this is the code I use to write data to the file : struct db line; if (!(data=fopen("data.dat","wb"))) { printf("Error opening file"); } /* strcpy(line.url,"http://www.ironmaiden.com");*/ line.url="http://www.ironmaiden.com"; line.test='T'; fwrite(&line,sizeof(line),1, data); fclose(data); return (0); and this is the code of the program I use to read the file struct db lineread; if (!(data=fopen("data.dat","rb"))) { printf("Error opening file"); } fseek(data, SEEK_SET, 0); fread(&lineread,sizeof(lineread),1, data); fclose(data); return (0); Please help me to find out what am I doing wrong. Thanks