If statement is being ignored when checking for index[0] of an array in C

Viewed 60

I'm trying to check if the index of a equals to + - / or * However when I run my program it seems to ignore my if statement.

How can I run the if statement when index of array a = to the above mentioned operators?

int main()
{
    double result = 0;
    char a[25] ;
    char b[25] ;

    char hold = a[0];
    while (a != 'quit')
    {

        printf("Calculate number: ");

        fgets(a, 25, stdin);
        x = a;

        if (hold == "+" || hold == '-' || hold == '/' || hold == '*') {//this is getting ignored


            sprintf_s(b, 25, "%lf", result);
            strcat_s(b, 25, a);
            x = b;
            printf("this is error");
        }
    
        result = parsesum();
        printf("result is:%lf \n", result);

    }
}
0 Answers
Related