base template always return 0 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

base template always return 0

but the template specialization works properly, why? https://code.sololearn.com/coCFFSxB4Q2r/?ref=app

16th Aug 2019, 9:41 AM
BinaryEden
BinaryEden - avatar
10 Answers
+ 1
The correct line is: cin >> character >> number; not cin >> character, number;
16th Aug 2019, 10:21 AM
Dennis
Dennis - avatar
+ 1
thx ~ swim ~ but problem persists: num always 35
16th Aug 2019, 11:43 AM
BinaryEden
BinaryEden - avatar
+ 1
~ swim ~ now throws error, check if u wish
17th Aug 2019, 11:43 AM
BinaryEden
BinaryEden - avatar
0
Dennis thx, but the problem persists when pass a char in number, it should return its ASCII num
16th Aug 2019, 10:35 AM
BinaryEden
BinaryEden - avatar
0
Did you enter 2 inputs? For example t 5 or t 5
16th Aug 2019, 10:36 AM
Dennis
Dennis - avatar
0
both does the same, returns 0 when pass char as number
16th Aug 2019, 10:41 AM
BinaryEden
BinaryEden - avatar
0
If you want the char to output its ascii value then you should also cast it to an int.
16th Aug 2019, 10:43 AM
Dennis
Dennis - avatar
0
Dennis casted it in the output f() but no works int(var) or int(var) so it must be casted before passing it to a func will use scanf and printf to doit, C always saving your ass
16th Aug 2019, 11:09 AM
BinaryEden
BinaryEden - avatar
0
yes, read it now I used scanf and printf and don't know why, now char empty and int 35
16th Aug 2019, 11:30 AM
BinaryEden
BinaryEden - avatar
0
yes, but mind while enter just chars it should return ascii num im using scanf and printf now maybe a sololearn's compiler bug?
16th Aug 2019, 12:12 PM
BinaryEden
BinaryEden - avatar