输入十位数时行不通了

int i = 1, n, m, p, q,t;
printf("Please input an integer:");
scanf("%d", &n);
t = n;//copy一个副本
printf("The result is:");
while ((n / 10) != 0){
n = n / 10;
i++;
}//到这 n不存在了
i = i - 1;
p = 1;
for (q = 1; q <= i; q++){
p = p * 10;
}
while (i >= 0){
m = t / p;
t = t - m*p;
printf("%d", m);
p = p / 10;
if (i % 3 == 0 && i != 0){
printf(",");
}
i = i - 1;

你这10位数超出int取值范围了