Secondly, in the same program I need to write another new file that take the same file as above and writes just the alphabetic data to a new file, with both keeping the same format (spacing/white space)
And lastly I cannot figure out the else and if for this program to write the second file. Any help would be greatly appreciated.
#include <fstream>
#include <iostream>
#include <cctype>
using namespace std;
int main ()
{
char ch;
ifstream fin;
ofstream fout;
//string filename;
if(fin.fail())
{
cout<<"could not open input file"<< endl;
exit(1);
}
else
{
fin.open("uppernumeric.txt");
fout.open("numeric.txt");
fin.get(ch);
}
if (fin.fail())
{
fin.open("uppernumeric.txt");
fout.open("alphabetic.txt");
fin.get(ch);
while(!fin.eof());
}
{
ch=isalpha(ch);
cout<<ch;
fout.put(ch);
fin.get(ch);
while(!fin.eof())
{
ch=isdigit(ch);
cout<<ch;
fout.put(ch);
fin.get(ch);
}
fin.close();
fout.close();
}
return 0;
}

New Topic/Question
Reply




MultiQuote




|