0
Reduce on char is not working
Why Reduce is not working for char type? https://www.sololearn.com/compiler-playground/crTD3J1hlGC0
4 Answers
+ 2
It appears to be working fine for me. It just works differently to other types used in the code; it works by accumulating each characters' ASCII value instead of concatenating the characters such as to form a string.
+ 1
That is also not correct as per my understanding...
I am getting output as 's' for vector char array of K,E,T,A and N
I was expecting 0 as output for below line but that's not 0
cout << int('K') + int('E') + int('T') + int('A') + int('N') - int('s') << endl;
is this analysis correct or Am i missing something else?
+ 1
Yes Ketan, that was correct. Accumulate ASCII value for each character 'K' , 'E', 'T', 'A', and 'N' then the result is assumed as letter 's' because the result overflow `char` type data range.
+ 1
Thanks Ipang
It works the way you are telling
vector<char> v = {'A',' '};
Space being 32 and A being 65 does give a = 65 +32
Thanks again for the insight