You need to initilize total to 0.
You need to initilize total to 0.
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.
FAQ > How do I... (Level 1) > How do I get a number from the user (C)
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
Or easier
Code:#include <stdio.h> int main() { char crap[2] = {'1', '3'}; int total = 0; int i; for (i=0; i< 2; i++) total += crap[i] - '0'; printf("%d", total); return 0; }
Last edited by andor; 09-17-2006 at 02:11 PM.