-1

I am working on a simple OS in C++, and am trying to implement the keyboard without using interrupts (yes I'm being lazy-) however the char* returned by the function only has one letter (the first one pressed) It uses a variable called MAX_16, which is simply 2^16 I'm making my own STDLIB and don't have access to most STDLIB functions.

char* scanf() {
    char* ret;
    for(int i = 0; i <= max_16; i++) {
        ret[i] = getkey();
        if(ret[i] == '\n') { return ret; }
    }
}

1 Answers1

1

ret is never initialized, so inside the loop, you are continually writing to garbage memory. Likely a fault is being triggered which causes the application to hang, causing no more input to be processed.

brenden
  • 574
  • 3
  • 16