weird response when counting the letters.
I have to count the letters that were inputted by the user. This a sample of my code and the answer in the console. (a the varibles are previously defined).
Code:
cout << " text:";
cin >> message;
let = 0;
// analysis part of the program //
while(let < message_length)
{
switch((int)message[let])
{
case 65: a++; break;
case 66: b++; break;
case 67: c++; break;
case 68: d++; break;
case 69: e++; break;
case 70: f++; break;
case 71: g++; break;
case 72: h++; break;
case 73: i++; break;
case 74: j++; break;
case 75: k++; break;
case 76: l++; break;
case 77: m++; break;
case 78: n++; break;
case 79: o++; break;
case 80: p++; break;
case 81: q++; break;
case 82: r++; break;
case 83: s++; break;
case 84: t++; break;
case 85: u++; break;
case 86: v++; break;
case 87: w++; break;
case 88: x++; break;
case 89: y++; break;
case 90: z++; break;
}
let = every_so_many_letters + let;
}
// Print the answer to screen //
cout << "\ta:\t" << a << endl;
cout << "\tb:\t" << b << endl;
cout << "\tc:\t" << c << endl;
cout << "\td:\t" << d << endl;
cout << "\te:\t" << e << endl;
cout << "\tf:\t" << f << endl;
cout << "\tg:\t" << g << endl;
cout << "\th:\t" << h << endl;
cout << "\ti:\t" << i << endl;
cout << "\tj:\t" << j << endl;
cout << "\tk:\t" << k << endl;
cout << "\tl:\t" << l << endl;
cout << "\tm:\t" << m << endl;
cout << "\tn:\t" << n << endl;
cout << "\to:\t" << o << endl;
cout << "\tp:\t" << p << endl;
cout << "\tq:\t" << q << endl;
cout << "\tr:\t" << r << endl;
cout << "\ts:\t" << s << endl;
cout << "\tt:\t" << t << endl;
cout << "\tu:\t" << u << endl;
cout << "\tv:\t" << v << endl;
cout << "\tw:\t" << w << endl;
cout << "\tx:\t" << x << endl;
cout << "\ty:\t" << y << endl;
cout << "\tz:\t" << z << endl;
the response:
Code:
a: 2088809675
b: 16384
c: 4008936
d: 2293440
e: 4335876
f: 2293560
g: 4408300
h: 4209872
i: 1
j: 2293424
k: 4404400
l: 2293552
m: 2
n: 0
o: 16777216
p: -1
q: 4424736
r: -1
s: 0
t: 0
u: 1
v: 4
w: 2293452
x: 8
y: 4008955
z: 2293488
No matter what text you put in and however long the char message ; part is, the same result comes and I don't get it. Hope some can help. :confused: