Write your question here.
Hi guys,
I am new c++ learner, I have stuck in copying the even values of myvector into a outfile stream, the program prints the required result on screen but when you see the created file it doesn't pop up the even values of the vector.
I would appreciated if anyone could help me out in this regard. Below is my coding.
int i, size=20;
vector <int> myvector;
for (i= 0; i<size; i++)
{
myvector.push_back(i);
cout<<"[ "<<myvector[i]<<" ]";
}
std:cout<<endl<<"\n";
even_outputfile(myvector,size);
return 0;
}
void even_outputfile(vector <int> &numb, int size)
{
int i;
for(i=0; i<size; i++)//loop to read even elements of the vector
{
if(numb[i]%2!=1)
{
std::cout<<"[ "<<numb[i]<<" ]";// prints the copied vector to the screen
}
}
std::ofstream output_file;