Hi I'm trying to make a program that returns the number of letters in a string but it seems that the function I have is not working as it returns 0 every time. Can someone check what I'm doing wrong? Thanks in advanced.
#include<iostream>
#include<string>
using namespace std;
unsigned letters(const string a);
int main(){
int i;
string a;
cin >> a;
cout << letters(a);
system("pause");
}
unsigned letters(const string a){
int i;
int countL = 0;
for(i=0;a[i]!='\0';i++){
if (a[i] >= 'A' && a[i] <='Z' && a[i] >= 'a' && a[i] <= 'z')
countL++;
}
return countL;
}