I have been trying to count the number of digits in an integer. I know I am close, but I am not quite sure what I am doing wrong. Could someone please point me in the right direction?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
usingnamespace std;
int main()
{
long A;
long B;
int n=0;
cout << "enter value: " ;
cin >> A;
cin.ignore();
if (1000000000 < A >= 0) {
++n;
(A /= 10);
cout << A << " is " << n << " digits long" << endl;
}
}
My output is always 1 for A. I know I am just misunderstanding something simple.
Thank you in advance for any help on this problem.