zozanthonyzoz 0 Newbie Poster

Hi all, I need to have a program to word count remove punctuation and sort it in alphabetical order.
I had done the word count portion but i am lost in removing punctuation and sorting in alphabetical order portion. Hoping to get some help.

#include <fstream>
#include <iterator>
#include <iostream>
#include <string>
#include <set>
#include <vector>
using namespace std;


int main()
{
int num2,x=0,y=0;
string num;
while(true)
{
cout<<"Please enter the threshold number: ";
getline(cin,num);
num2=atoi(num.c_str());
if(num2<=0)
{
cout<<"Invalid Number."<<endl;
}
else
{
break;
}
}
ifstream f("sample.txt");
istream_iterator<string> eof;
multiset<string> words( istream_iterator<string>(f) , eof);
ofstream fout; 
ofstream fout2;
fout2.open("index.txt");
fout.open("common.txt");
for( multiset<string>::iterator i = words.begin(); i!=words.end(); i = words.upper_bound(*i) )
{
if(words.count(*i) >= num2)
{
x++;
fout << *i << " " << words.count(*i)<<endl;
}
else
{
y++;
fout2<< *i << " " << words.count(*i)<<endl;
}
}
fout<<"Total Number: "<<x<<endl;
fout2<<"Total Number: "<<y<<endl;
fout.close(); 
fout2.close();
return 0;

}