tinycities
Programmer
I posted last night regarding my sort function, however, it turns out that wasn't the problem at all, it was my write function. I have since fixed that problem within my write function. The problem I'm dealing with now, is that my read func. seems not to be getting the final number from my input file. I've pasted both my read and write funcs. below. (in case it's actually a write error). The output is good, except that it excludes that final number.
void read (istream& in_str, int arr[], int size, int& num_used)
{
for(int index = 0; index < size-1 && in_str >> arr[index]; index++)
{
num_used = index;
}//end for
}//end read
void write (ostream& out_str, int arr[], int size, int& num_used)
{
for (int index = 0; index < size && index < num_used; index++)
{
out_str << arr[index];
out_str << " ";
}
out_str << endl;
}
void read (istream& in_str, int arr[], int size, int& num_used)
{
for(int index = 0; index < size-1 && in_str >> arr[index]; index++)
{
num_used = index;
}//end for
}//end read
void write (ostream& out_str, int arr[], int size, int& num_used)
{
for (int index = 0; index < size && index < num_used; index++)
{
out_str << arr[index];
out_str << " ";
}
out_str << endl;
}