New to programming, I'm looping through a postfix string and trying to retrieve the numbers individually, I only need one at a time.
Initially I wrote this for integers and just did "- '0'", however, I now need to try and make it compatible for decimal numbers.
An example of my integer conversion is below, how could I adapt this?
int i;
char postfix[] = "4 3 +";
for (i=0; i<strlen(postfix); i++) {
if (isalnum(postfix[i])) {
int value=(postfix[i]-'0');
printf("%d\n", value);
}
}
4
3
e.g. how to evaluate when
char postfix[] = "1.2 3.4 +"
storing the value as a double