C语言 帮慢看看这题关于加减问题的
我在主函数输入几个数相加或相减想要得出结果,输入的式子都得加个空格,例如:34 +23 -14就像这样;可是我想要的是不用加空格该怎么做void recon(char arr[], int *value);
int main() {
char arr[250];
char ch = 0;
int value = 0;
int a = 0;
int c = 0 ;
int i = 0;
scanf("%s", arr);
recon(arr, &value)
printf("%d\n", value);
}
void recon(char arr[], int *value) {
char temporary[250];
char ch = 0;
size_t at = 0;
char c = 0;
bzero(temporary, sizeof(char) * 32);
if (arr[0] == '+' || arr[0] == '-') {
temporary[at++] = arr[0];
printf("1:%s\n", temporary);
}
do {
ch = arr[at];
if (ch == '+' || ch == '-' || ch == 0) {
printf("4:\n");
break;
} else {
temporary[at++] = ch;
printf("2:%s\n", temporary);
}
} while (1);
printf("3:%s\n", temporary);
*value = atoi(temporary);
}