using isalpha fuction

hey guys just wanted to know where in my code can i place the isalpha function to ignore digits and other puntuations...my code runs by the way.....thanks in advance

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
 // string::size
#include <iostream>
#include <string>
#include <fstream>
using namespace std;

int main ()
{
  std::string str;
  ifstream infile("input.txt");

  int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;
  int num=0;

  while(!infile.eof())
  {

       infile>>str;

       for(int i=0;i<str.size();i++)
       {

           if(str.size()==1)
           {
               a++;
           }
            if(str.size()==2)
           {
               b++;
           }
           else if(str.size()==3)
           {
               c++;
           }
           else if(str.size()==4)
           {
               d++;
           }
           else if(str.size()==5)
           {
               e++;
           }
           else if(str.size()==6)
           {
               f++;
           }
           else if(str.size()==7)
           {
               g++;
           }
           else if(str.size()==8)
           {
               h++;
           }
           else if(str.size()==9)
           {
               i++;
           }
           else if(str.size()==10)
           {
               j++;
           }
           str.clear();

}

}
  cout<<a<<"  "<<b<<"  "<<c<<"  "<<d<<"  "<<e<<"  "<<f<<"  "<<g<<"  "<<h<<"  "<<i<<"  "<<j<<endl;
return 0;
}
Yes you can
i got the code working here it is
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
 
// string::size
#include <iostream>
#include <string>
#include <fstream>
#include <cctype>
using namespace std;

int main ()
{
  std::string str;
  ifstream infile("input.txt");

  int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;
  int num=0;

  while(!infile.eof())
  {

       infile>>str;

       for(int i=0;i<str.size();i++)
       {

           if((str.size()==1)&&(isalpha(str.at(i))))
           {
               a++;
           }
            else if((str.size()==2)&&(isalpha(str.at(i))))
           {
               b++;
           }
           else if((str.size()==3)&&(isalpha(str.at(i))))
           {
               c++;
           }
           else if((str.size()==4)&&(isalpha(str.at(i))))
           {
               d++;
           }
           else if((str.size()==5)&&(isalpha(str.at(i))))
           {
               e++;
           }
           else if((str.size()==6)&&(isalpha(str.at(i))))
           {
               f++;
           }
           else if((str.size()==7)&&(isalpha(str.at(i))))
           {
               g++;
           }
           else if((str.size()==8)&&(isalpha(str.at(i))))
           {
               h++;
           }
           else if((str.size()==9)&&(isalpha(str.at(i))))
           {
               i++;
           }
           else if((str.size()==10)&&(isalpha(str.at(i))))
           {
               j++;
           }
           str.clear();

}

}
  cout<<a<<"  "<<b<<"  "<<c<<"  "<<d<<"  "<<e<<"  "<<f<<"  "<<g<<"  "<<h<<"  "<<i<<"  "<<j<<endl;
return 0;
}
Topic archived. No new replies allowed.