Code:
char hours_array[5] = {'1','5','9','7','4'}; // value is 1234
You don't really want to end up with 1234 out of this, do you?
I was thinking of something like this:
Code:
#include <stdio.h>
int main(int argc, char *argv[]) {
int lc_count;
int tmp2, tmp=0;
int array_mult = 1;
char array[5] = {'1','5','9','7','4'}; // value is 1234
int i = 4;
for(i = sizeof(array)-1, tmp2 = 0; i > -1; i--) {
tmp2 = array[i] - '0';
tmp2 *= array_mult;
tmp = tmp + tmp2;
array_mult *= 10;
}
printf("count value is: %d \n" ,tmp);
system("PAUSE");
return 0;
}