What purpose does that serve? |
None whatsoever. I'm kind of assuming that Satchmo's spammed a couple dozen other forums with this program if he posted it here twice. He's probably getting plenty of help at one of those. And besides, I helped him get his program inside a
code
tag, didn't I?
Whatever, let's take a look at this:
#include <sys/types.h>
What's up with the slash? Is this normal? I vaguely recall having to try this once years ago and I ended up having to reinstall CodeWarrior before very long. I'm not trying to nitpick ... I just never see this and it makes me wonder if a development system has been corrupted somehow or another.
int count = 0, array[MAX_SIZE], next;
Why do we keep strings in vectors but we make arrays for integers? Just cut the array out and make yourself a vector <int> instead. You'll be lots happier in the long run.
1 2
|
void OpenInputFile(ifstream& in_file, char string);
void OpenOutputFile(ofstream& out_file, char string);
|
I believe someone already mentioned the foolhardiness of using "string" as the name of a variable when it's already the name of a class defined within the program. This could very well be the entire problem, but until you solve it and try to run the program again you won't know for sure.
float average_temp, maximum_temp;
You're really not going to need a floating-point variable for the maximum of a list of
integers. An int would do fine.
intro = "C://*/*/*/*/*/*/*/";
Is there a reason for that? I'm not saying there couldn't be, by any means, I'm just wondering.
stringVector files = stringVector();
You don't really have to call the default constructor like this. That's why they call it the default constructor. Not calling one at all would have the same effect. In fact I really couldn't swear that this line is legal C++ at all, since initializing a stringVector with a parameterized constructor would read like
stringVector files (v) ;
,
assuming
v to be, for instance, a vector to copy.
...
I don't even know where to start about the complications you've introduced into the simple process of opening two text files for reading and two for writing. Towards the beginning of the program you obtained a string representing the directory from the user, right? All you need to open fstreams at will now is to append filenames to that string (in various copies, of course). And don't hard-code "January" and "Februrary" into the file names because next month you don't want to have to edit these source files just to get the same totals and averages, right? Let the computer figure out what the name of the file ought to be. It has a clock for just such a purpose. Call a date() function or something and parse the month out of it. For that matter, demand the exact names of the files from the user, who for all you know misspelled the name of the month when he/she named the files in the first place.
I also think passing the entire array[] of integers as the parameter to a function could be causing you problems if the routines you pass it to alter any of the values stored in it, but we already decided the damn thing should really be a vector <int> anyway, right?
Finally, while it looks to me like your function to calculate the average of these numbers will probably work all right, this...
1 2 3 4
|
float CalcMax(int array[])
{
return 0;
}
|
is pretty much doomed to failure, don't you think? ROFLMAO Even if all of the integers in array[] are negative ZERO is still the wrong $&#*ing answer unless 0 happens to be in the array as well by some happy coincidence. And, as I pointed out before, the maximum of a set of integers is quite likely to itself be an integer.
Now I hope I've helped to steer you in the right direction on this project.
There. Everybody happy now? :)