Hi,
I tried to get a simple application running that does prime factorial decomposition. The algorithm works, i tested it without the calulator. I dont know how to properley get user input tho.
Code:
I believe setting resetting the buffer causes the issue. The first input and displaying works, however, when I try to enter a number a second time, i get this error:
Code:
Any help would be appreciated
I tried to get a simple application running that does prime factorial decomposition. The algorithm works, i tested it without the calulator. I dont know how to properley get user input tho.
Code:
#include <fxcg/display.h>
#include <fxcg/keyboard.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int* primeFactors(int n);
char* primeFactorsAsString(int n);
int main() {
PrintXY(1, 1, "--Primfactorzerlegung", TEXT_MODE_NORMAL, TEXT_COLOR_BLACK);
char *buffer = (char*) malloc(256);
int start = 0;
int cursor = 0;
buffer[0] = '\0';
int key;
DisplayMBString((unsigned char*) buffer, start, cursor, 1, 2);
while (1) {
GetKey(&key);
if (key == KEY_CTRL_EXE) {
int input = atoi(buffer);
char bufferTwo[102] = "--";
strcat(bufferTwo, primeFactorsAsString(input));
PrintXY(1, 3, bufferTwo, TEXT_MODE_NORMAL, TEXT_COLOR_BLACK);
buffer = "";
} else if (key && key < 30000) {
cursor = EditMBStringChar((unsigned char*) buffer, 256, &cursor, &key, 1, 2);
DisplayMBString((unsigned char*) buffer, start, cursor, 1, 2);
} else {
EditMBStringCtrl((unsigned char*) buffer, 256, &start, &cursor, &key, 1, 2);
}
}
return 0;
}
}
I believe setting resetting the buffer causes the issue. The first input and displaying works, however, when I try to enter a number a second time, i get this error:
Code:
System ERROR
REBOOT : [EXIT]
INITIALIZE: [EXE]
TLB ERROR
TARGET=0030202F
PC =00301F30
Any help would be appreciated