Here's the deal. I need program to read from text txt file and then write numbers into one file and letters into the other...
I figured how to read and write to file (using iterators) but I can't figure out how to make the program sort numbers from letters.
#include "stdafx.h"
#include <iostream>
#include <ostream>
#include <fstream>
#include <list> using list container is required
#include <string>
using namespace std;
template <typename T>
class Zavd{
int n;
list <T> data; char c;
public:
Zavd(int n1=0);
void Read ();
void Write();
void Numbers();
void Letters();
//~Zavd();
};
template <typename T> Zavd <T>::Zavd(int n1)
{n=n1;
}
template <typename T> void Zavd <T>::Write()
{
ofstream flout("Out.txt");
flout<<"Output:\n";
list <char>::iterator p1;
p1=data.begin();
for (p1=data.begin(); p1!=data.end(); p1++)
{
flout<<" "<<*p1<<endl; }
flout<<"\n";
flout.close();
}
template <typename T> void Zavd <T>::Read()
{
ifstream flin("In.txt");
flin>>n;
for (int i=0; i<n; i++)
{flin>>c;
data.push_back(c);
}
//data.pop_front();
flin.close();
}
//template <typename T> Zavd <T> ::~Zavd
template <typename T> void Zavd<T>::Numbers()
{int i;
list<char>::iterator p2;
//data.sort();
{cout<<"number"<<endl;}
for(p2=data.begin(); p2!=data.end(); p2++)
{
{if( data.back()==4)
{cout<<"number"<<endl;
} }
cout<<*p2<<endl;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
Zavd <char> A;
A.Read();
A.Numbers();
A.Write();
system ("pause");
return 0;
}
Usage of list container is required.
any suggestions??