+ 1
Why this ptogram gives negative value for year?
3 odpowiedzi
+ 3
you must add i++; to line 21,22 otherwise you’ll use the ascii value of ‘/‘
but you probably already know this since you’ve done a similar thing at line 17
+ 2
the ascii value of “/” is 47 and you subtract 48 and this is why the output is NEGATIVE ...
for example if your input is “20/01/2003” (as you have commented in your code...)
the output will be :
-10000+2000+000+00+3 = -7997
i++; at line 22 will fix this...
0
Stop using C-style in c++ for real