string temp = "ACB ME BAT"
and i want convert A->1 B->2... so on and convert temp to certain number
A C B space
(1*1) + (3* 2) + (2 * 3) + ( 0 * 4).......
but when i do
for( int i=0 ; i < temp.size() or temp.length() ; i++)
it only read size one by one
but i want to read the whole string as one word (not one by one)(include space)
also iterator shows the same problem.
is there any string methods useful for this problem?
or read whole space string as one?
Oh
1 2 3 4 5 6 7 8
|
string temp
cin>> temp;
cout << temp.length() <<endl;
for(int i=0 ; i < temp.length() ; i++){
cout << temp[i] <<endl;
}
| |
if I input stream string as "hello my name is"
temp.length() is not 15
its 5,2,4,2
which make me difficult to solve the problem
Last edited on