|
-
Oct 7th, 2002, 09:00 AM
#1
No, you would read it in a string, not a buffer. And it is meant for the file names.
#include <string>
#include <iostream>
using namespace std;
string sFileName;
getline(cin, sFileName);
Don't be too fixed on the copy_file and write_out and read_in functions. Basically you read need a struct that holds one block of info. Then you declare a static array of 100 such blocks. Then you read in the file into the array while counting how many blocks you actually read. Then you sort the array. Then you write the array out to the other file.
This means you need a main function which does (in pseudo-code)
Code:
string inFile = ReadAndValidateInFileName();
string outFile = ReadOutFileName();
datablockstruct blocks[100];
int numBlocksRead = ReadFile(inFile, blocks);
SortArray(blocks, numBlocksRead);
WriteFile(outFile, numBlocksRead);
You already have ReadAndValidateInFileName and ReadOutFileName. You also have SortArray. You only need to write ReadFile, datablockstruct and WriteFile.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|