okey dokey -
Code:
#include<iostream>
#include<vector>
#include<fstream>
using namespace std;
void display( vector<int> vec)
{
for ( int ix = 0; ix < vec.size(); ++ix)
cout<<vec[ix]<<' ';
cout<<endl;
}
void swap( int &val1, int &val2)
{
std::ofstream ofil<<"swap( "<<val1
<<", "<<val2<<" )\n";
int temp = val1;
val1 = val2;
val2 = temp;
ofil<<"after swap(): val1 "<<val1
<<" val2: "<<val2<<"\n";
}
ofstream ofil("E:\\text_out1");
void bubble_sort(vector<int> &vec)
{
for(int ix = 0; ix<vec.size(); ++ix)
for(int jx = ix+1; jx<vec.size(); ++jx)
if(vec[ix]>vec[jx]){
//debugging output
std::ofstream ofil<<"about to call swap!"
<<" ix: "<<ix<<" jx: "<<jx<<'\t'
<<" swapping: "<<vec[ix]
<<" with "<<vec[jx]<<endl;
//ok actual swap code...
swap(vec[ix], vec[jx]);
}
}
int main()
{
int ia[8] = {8, 34, 3, 13, 1, 21, 5, 2};
vector<int> vec(ia, ia+8);
cout<<"vector before sort: ";
display(vec);
bubble_sort(vec);
cout<<"vector after sort: ";
display(vec);
cin.get();
return 0;
}
I'm using Dev C++, and I get "expected primary-expression before 'ofil' " and "expected ';' before ofil"
I still don't get it!
- JM