Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

input output from Binary file !! 1

Status
Not open for further replies.

zavrisky

Programmer
Oct 6, 2001
7
AU
I have a text based database and it looks like this :
269,N,1,1,That's a good news
269,N,1,2,that you are going on and on
273,A,14,16,Sadek,NOTHIONG
278,T,Call Fardous and invite

Each of the lines indicate a day's activitity and speparated by the delemeter , (comma). My program reads this database as well writes on the screen and in files. Now, I want to convert the text based data file into Binary file. I want to use fread and fwrite and sperate each lines and each fields according to the delemeter. Can anyone tell me how to do that?
 
char routine[4][40]= {
"269,N,1,1,That's a good news",
"269,N,1,2,that you are going on and on",
"273,A,14,16,Sadek,NOTHIONG",
"278,T,Call Fardous and invite" };
char temp[40];
FILE *fp;

/*open file to write binary*/
fp = fopen(filename, "wb");
/*write to file*/
for(i = 0; i < 4; i++)
{
fwrite(routine, sizeof (routine),1, fp);
}
fclose(fp);
/*open file for reading*/
fp = fopen(filename, &quot;rb&quot;);
/*read and print to screen file*/
for(i = 0; i < 4; i++)
{
fread(temp, sizeof (temp),1, fp);
printf(temp);
}
fclose(fp);
or you could use structures......... Hoping to get certified..in C programming.
 
Thanks very much bigtamscot.
That was a great help. Cheers
and thanks a bunch again :)
 
can anyone tell make to database connectivity using turbo c++ or vc++ in easy steps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top