![]() |
Help with variable-length fields
Anyone know where I can get a program that will make use of variable-length fields and variable-length records and convert a file to using variable length.
|
Re: Help with variable-length fields
You're going to have to rephrase that question so it actually makes sense.
|
Re: Help with variable-length fields
Okay so say I there is a program that generated a file but it is in fixed length records. How would I go about writting a program that changes a file into using variable lenght fields and variable lenght records.
|
Re: Help with variable-length fields
Starting to make more sense. What do you mean by "fixed-length records?" Can you give me an example of what you have currently and what you'd like it to be after you change it?
|
Re: Help with variable-length fields
Nothing wrong with using fixed-length records, they actually have a lot of advantages over variable length records. Do the fixed-length records contain binary data and you want to convert them to readable text data? If that's the case then you can fairly easily write a conversion program that reads the fixed length records and rewrites them as variable length records into a different file. I've done it several times and it pretty simple stuff, providing you know the format of the fixed length binary records.
|
Re: Help with variable-length fields
Okay so you have info like for example this....
Field/ Name/ Fixed length 1/ SS#/ 9 2/ Last Name/ 25 3/ First Name / 15 4/ Address / 30 5/ City / 25 6/ State code / 2 7/ Zip code / 5 8/ # courses / 2 But some of the things do not need to be fixed length. Others are fine that way but some would be better as variable length |
Re: Help with variable-length fields
That looks as if someone wrote out the file in binary mode using a structure
:
struct person:
ofstream out("filename",ios::binary);You can read that in very quickly like this :
struct person John;Note that you don't have to read/write each field one at a time, and you can quickly access any record in random order by simply seeking to the desired spot. I see no advantage of converting that to a standard text file unless you want to view it by some standard text editor such as Notepad. But if you still want to convert the file just write a simple console program that reads in old format and writes in new format. I've already given you some code to work with that reads with the old format. Should be fairly straight-forward for you to write the code to rewrite into the new format, assuming you have the basic knowledge about how to read/write files. Just in case you need help with that too: :
ofstream out("newfile"); |
Re: Help with variable-length fields
thanks that helped a lot!
|
| All times are GMT -5. The time now is 4:04 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC