xiaolim
July 29th, 2008, 06:25 AM
hi, i am still new to c++, as well as in this forum, my apologies to those who are in the visual c++ side, i should have posted my question. i am sorry.
so here is my code,
#include <iostream>
#include <cstring>
#include <fstream>
#include <conio.h>
using namespace std;
int main(void)
{
int total=0;
int upper=0;
int lower=0;
int digits=0;
int blanks=0;
int eosp=0;
int others=0;
char buf[80];
ifstream fin;
string fname;
cout << "Welcome\n" << endl;
cout << "This programe will analyze the file content &" << endl;
cout << "compute the statistics of the file you input.\n\n\n\n\n" << endl;
system("pause");
system("cls");
do
{
cout << "Enter input data file name:\n";
cin >> fname; // Get the file name.
fin.open(fname.c_str()); // Convert to C-string and open it.
if (!fin)
{ // Will fail if didn't exist.
cout << "Unable to open " << filename << endl;
cin.get();
system("cls");
}
} while(!fin);
cout << "Total number of characters: " << total << endl;
cout << "Number of uppercase characters: " << upper << endl;
cout << "Number of lowercase characters: " << lower <<endl;
cout << "Number of decimal digits: " << digits << endl;
cout << "Number of blanks: " << blanks << endl;
cout << "Number of end-of-sentence punctuation marks: "<< eosp << endl;
cout << "Others: " << others << endl;
cout << "" << endl;
system("pause");
return 0;
}
i wanted it to detect the uppercase, lowercase,digits,blanks, punctuations and others such as spaces. I've declare all the variables and assign them to initial 0.so after the file is open, the program should be able to read all the lines in the file and detects and then display them out as accordingly. any guide or help? an example will be more then enough. thank you very much
so here is my code,
#include <iostream>
#include <cstring>
#include <fstream>
#include <conio.h>
using namespace std;
int main(void)
{
int total=0;
int upper=0;
int lower=0;
int digits=0;
int blanks=0;
int eosp=0;
int others=0;
char buf[80];
ifstream fin;
string fname;
cout << "Welcome\n" << endl;
cout << "This programe will analyze the file content &" << endl;
cout << "compute the statistics of the file you input.\n\n\n\n\n" << endl;
system("pause");
system("cls");
do
{
cout << "Enter input data file name:\n";
cin >> fname; // Get the file name.
fin.open(fname.c_str()); // Convert to C-string and open it.
if (!fin)
{ // Will fail if didn't exist.
cout << "Unable to open " << filename << endl;
cin.get();
system("cls");
}
} while(!fin);
cout << "Total number of characters: " << total << endl;
cout << "Number of uppercase characters: " << upper << endl;
cout << "Number of lowercase characters: " << lower <<endl;
cout << "Number of decimal digits: " << digits << endl;
cout << "Number of blanks: " << blanks << endl;
cout << "Number of end-of-sentence punctuation marks: "<< eosp << endl;
cout << "Others: " << others << endl;
cout << "" << endl;
system("pause");
return 0;
}
i wanted it to detect the uppercase, lowercase,digits,blanks, punctuations and others such as spaces. I've declare all the variables and assign them to initial 0.so after the file is open, the program should be able to read all the lines in the file and detects and then display them out as accordingly. any guide or help? an example will be more then enough. thank you very much