I'm reading in a bunch of numbers into a char array, and then I want to perform mathematical operations on these numbers.
I've read the FAQ > Explanations of... > Definition of EOF and how to use it effectively where they talk about the promotion, but I'm still not sure if I can do what I want to do. Or maybe there's another way.
say I have and input like so:
I read it in one character at a time. so a string would contain:
1 2 6
Now I want to assign the value 126 to an int. In the code count represents the number of characters read in. I can't read in the characters differently because the file contains letters and numbers and the reading function reads one char at a time.
int ConvertNum(FILE *inp, char *string, int count)
int i /*position*/, j =0 /*power*/, num =0, temp;
for (i=(count-1); i >=0; i--)
temp = string[i];
num = num + temp * (10^j);
printf("temp = %d, string[i] = %c \n", temp, string[i]);