Organizational Research By

Surprising Reserch Topic

c pointer manipulation in switch statement

c pointer manipulation in switch statement  using -'c,operator-precedence,post-increment'

Hi folks i tried to program a simple switch statement and stuck uppon this problem.
I cant figure out why this code works correctly, i guess it is because the precedence of the operators ** and ++.
If this is the case ill be happy if someone can write an example how should i use value-at * and inc/dec operator in a statement like below.

Thanks in advance,

while (--argc > 0)
        switch (**argv)

and this code dont

while (--argc > 0)
        switch (**(argv++))

Full code:

while (--argc > 0) {
        switch (**(argv++)) {
        case '\0':
            panic("empty command line argument");
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
            push (atof(*argv));
        case '+':
            push(pop() + pop());
        case '-':
            op2 = pop();
            push(pop() - op2);
        case '*':
            push(pop() * pop());
        case '/':
            op2 = pop();
            push(pop() / op2);
            panic("unknown command");


asked Sep 9, 2015 by TerMonteneg
0 votes

Related Hot Questions

Government Jobs Opening