I am working my way through the "credit" challenge one piece at a time. My current code, although incomplete for the full challenge, ought to be functional for what it is: it is supposed to take every other digit of the number entered, starting with the second-to-last one and moving in the direction of the first one; multiply each one of those digits by two; and add the result of each of these multiplications to a variable called "total".
My code is here: https://repl.it/JT3S/2 (Unfortunately you can't run it in repl.it due to the absence of the cs50.h library, but at least you can see it, and I tried to use sensible variable names and comment it clearly to help orient the reader.)
I split the whole thing up into separate functions for clarity. The problem appears to be in the function "addmultbytwo", specifically on line 62, I believe.
Here is a screenshot of my terminal when I run the current code (I added a bunch of "printf" lines for line-by-line debugging, which results in all the text you see):
Note that right after I give it my input, the "currentcc" (user-inputted number, in this case 12341234123412) is displayed correctly. The next line is also correct: it "pops off" the last digit, 2. In the line after that, however – the one that starts "getlastdigitofthis is currently" – the number has suddenly changed completely! So clearly that's where the error lies... but what IS the error?
Any advice is greatly appreciated!