By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,750 Members | 1,221 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,750 IT Pros & Developers. It's quick & easy.

Handling large records in C

P: 12
Pls tell how to handle large records in C using files .The records contain name, code, address etc,......
Sep 25 '06 #1
Share this Question
Share on Google+
8 Replies


Banfa
Expert Mod 5K+
P: 8,916
The question is not really clear, create a structure for each record.
Sep 25 '06 #2

P: 12
pls provide some related code
Sep 25 '06 #3

Banfa
Expert Mod 5K+
P: 8,916
pls provide some related code
Expand|Select|Wrap|Line Numbers
  1. struct record {
  2.     char name[MAXNAME];
  3.     unsigned code;
  4.     char address[MAXADDRESS];
  5. };
  6.  
Sep 25 '06 #4

P: 12
pls tell how to write info in file. Thanks
Sep 25 '06 #5

Banfa
Expert Mod 5K+
P: 8,916
pls tell how to write info in file. Thanks
look up the functions

fopen
fclose
fread
fwrite
Sep 25 '06 #6

P: 12
Thanks
But problem is that the fread and fwrite are fro binary files.
I want to write the infromation in the following format in text files:
Record-1 Name Age .......
Record-2..

Pls check
Sep 26 '06 #7

P: 12
pls check how to write in text file and read the same form text file and with proper formatting,
Sep 27 '06 #8

Banfa
Expert Mod 5K+
P: 8,916
Thanks
But problem is that the fread and fwrite are fro binary files.
I want to write the infromation in the following format in text files:
Record-1 Name Age .......
Record-2..

Pls check
In that case look up

fputs
fprintf

Just because fread and fwrite are for binary data doesn't stop you using them to write text. text is binary data too as far as the computer is concerned it is just you that chooses to view it differently.
Sep 27 '06 #9

Post your reply

Sign in to post your reply or Sign up for a free account.