"sort odd file
sort even file"
i cant read files more then once??
" append to odd ? odd file : even"
what this means?
i know the ? : form
what you mean here?
"sort odd file
sort even file"
i cant read files more then once??
" append to odd ? odd file : even"
what this means?
i know the ? : form
what you mean here?
Ohh man, you really need help. He gave a whole lot of hints
I am waiting for Quzah's comments
-ssharish
Life is like riding a bicycle. To keep your balance you must keep moving - Einstein
You don't have to read a file to append to it. Therefore, since you can only read each file once:
1 - Open the mixed file for reading.
2 - Open output.odd in append mode.
3 - Open output.even in append mode.
4 - Read the input file, appending as you go to the appropriate file.
5 - Close the input all the files.
6 - Open one of the output files for reading/writing.
7 - Read it into memory and sort it.
8 - Write it.
10 - Do steps 6 through 8 for the other output file.
There. Each file has been read only one time.
Quzah.
Hope is the first step on the road to disappointment.
i am not allowed to use append
only "r" for the input
and "w" for the two output files
I doubt that. You aren't telling us the full requirements. How about in the future you actually tell us what the requirements of your homework are, since we're doing all the work here anyway. That way it will save us all a bunch of time.
You cannot perform this task in the manner you describe. Without being able to sort the data in memory, and with only being able to open in write mode, and with only being able to read through the input file once, and limiting yourself to two output files, you cannot do this task as you've described.
You're either not understanding the question, or are making stuff up because you don't like the answers you were given. If you cannot sort the file on disk, then you MUST sort it in memory. That's all there is to it. You either read through the file a bunch of times, or you read it once and sort it in memory. Pick one.
Quzah.
Hope is the first step on the road to disappointment.
ok ill try to implement your solution.
nut i cant understand what append mode does.
i read in the manual of c++ that its "writing from the end"
so its moving the EOF forward and replacing the empty new space with the new data??
Append mode works just like write mode, with the difference that it does a fseek(file, 0, SEEK_END) - that is, it positiions the "where to access the file next" at the end of the file, so when you write to it, it adds to the end of the file, rather than writing at the first location of the file.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
can you see a solution which uses
my helping function??
i am supposed to use it in the solution somehow
?
is there a way?
I've already told you, you are either going to have to read your file(s) more than once, or you're going to have to sort the entire thing in memory.
Quzah.
Hope is the first step on the road to disappointment.