??? 06/06/07 16:52 Modified: 06/06/07 17:17 Read: times |
#140324 - No, Andy -- Joe\\\'s answer is not correct Responding to: ???'s previous message |
Joe said:
for i = 0 - 3 { D_i = string_number_i - 48 value = D_i*10^i } You were a little quick on the trigger, there, Joe. In order for this to work, 'value' has to be initialized before the loop, and you have to add each new term to it within the loop. As you have it, the end result will be (1000 * D_4), which is not what you had in mind. Having said that, however, since the OP is already using scanf(), a simpler solution is to just do the conversion directly as the input as read, like this: scanf("%4d%4d%4d%4d", &a, &b, &c, &d);No fuss, no muss, and no need for the OP's 'buf'. -- Russ |