从文件中扫描两位数。两位数分开

时间:2015-07-19 17:06:46

标签: c

我正在研究一个Postfix计算器。我尝试了fscanffgets两个单独的双位数字。当我扫描文件时,两个数字分别在代码中继续。 25将是25

char Operand[20];

    fgets(Operand, 20, Filepath);
    for(i = 0; i < strlen(Operand); i++){

        if(Operand[i] == ' ' ){

             continue;
        }

        if( isdigit(Operand[i])){


            PushOperand = (char *)malloc(sizeof(char));
            *PushOperand = Operand[i];

            Push(stack, PushOperand );


        }
        else{

            num1 = Pop(stack);
            num2 = Pop(stack);
            number1 = atoi(num1);
            number2 = atoi(num2);
            operator = Operand[i];
            value = GetValue(operator, number1, number2);
            pushVal = &value;
            Push(stack, pushVal);

        }

    }

0 个答案:

没有答案