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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insertion in to files (Last first) URGENT

Status
Not open for further replies.

Striker99

Programmer
Oct 31, 2001
34
UA
I have an application which is supposed to write data into a file in the reverse order. The values are stored in four strings S1, S2, S3 and S4. The length of each string is variable.

Following is the algorithm:
1. Open the File.
2. Write S1
3. Move to the beginning of the file.
3. Write S2
4. Move to the beginning of the file.
5. Write S3
6. Move to the beginning of the file.
7. Write S4
8. Close the file.

On completion the intended sequence in the file should be as follows:
<S4>,<S3>,<S2>,<S1>

The problem is that the current string seems to overwrite the previous one completely or partially depending on the length of the former.

Anybody knows how I could overcome this problem?
 
Why don't you

1. Open the File.
2. Write S4
3. Write S3
4. Write S2
5. Write S1
8. Close the file

?
 
or

CFile file;
write data
seekToBegin
write data
rinse and repeat

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top