I have this piece of code, used as a debugging tool:
printf("%d", p->digits[0]);
printf("%d", p->digits[0]);
It printed out 21. This is logically impossible, and it's not a junk number. I tried putting just the first line alone, and even the first line alone with different indexes and got correct output.
I figure the only possible way to get this error, and the trash numbers I got from
printf("%d", p->digits[0]);
printf("%d", p->digits[1]);
Is some sort of buffer flushing. How do I flush buffers in printf?
As a side note, p points to a structure from main() that I'm manipulating within a function. I don't think that's the problem though.