This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

return error

coded so far

int pushintomemory(unsigned char *buffer,int offset) { int i = 0; for(;;) { if(buffer[offset + i] == 0x90) { i++; } else { break; } else { j = i+2; } if(i == 5) { i = rand()%3 + 3; break; } } return i;
}

Parents
  • What was wrong with:

    int pushintomemory(unsigned char *buffer,int offset) {
        int i = 0;
    
        for (;;) {
            if (buffer[offset + i] == 0x90) {
                i++;
            } else {
                break;
            } else {<===== two else for one if??? How do you get this through the compiler???
                j = i+2;
            }
            if (i == 5) {
                i = rand()%3 + 3;
                break;
            }
        }
    
        return i;
    }
    

    Besides trying to have two "else" with one "if", your code doesn't look like it would make sense.

    Why have an infinite loop that either contain break or do not update variable i? Is it expected to skip an unknown number of buffer values 0x90? Why even have a rand() in your code, without any source code comments very clearly explaining what you think the code is expected to solve?

Reply
  • What was wrong with:

    int pushintomemory(unsigned char *buffer,int offset) {
        int i = 0;
    
        for (;;) {
            if (buffer[offset + i] == 0x90) {
                i++;
            } else {
                break;
            } else {<===== two else for one if??? How do you get this through the compiler???
                j = i+2;
            }
            if (i == 5) {
                i = rand()%3 + 3;
                break;
            }
        }
    
        return i;
    }
    

    Besides trying to have two "else" with one "if", your code doesn't look like it would make sense.

    Why have an infinite loop that either contain break or do not update variable i? Is it expected to skip an unknown number of buffer values 0x90? Why even have a rand() in your code, without any source code comments very clearly explaining what you think the code is expected to solve?

Children
No data