As pointed out in second comment, what you're getting ASCII value of '1'
character. What you'll need to do is something like this:
int temp = (int) (*infix - '0');
Also, you should use fgets()
for taking string input. I wasn't able to compile your code, so I made some minor changes. Here is what I tested:
#include <stdio.h>
#include <string.h>
int main() {
char infix[10];
fgets(infix, 10, stdin);
infix[strlen(infix)-1] = '\0';
char *pArr = infix;
while (*pArr != '\0') {
int temp = (int) (*pArr - '0');
printf("%d\n", temp);
pArr++;
}
}
When I ran this, I was getting expected output:
src : $ ./a.out
123
1
2
3