1
Calculator C / crash after calling function twice
« on: May 24, 2010, 12:28:30 pm »
Hi there!
I'm trying to get into c programming for nspire (actually I'm trying to get into c programming at all )
I can have a very simple function, say to draw a dot of 2*2 pixels.
The function works just fine and draws my dot, but when the function is called for a second time the nspire crashes.
Here is the code I use:
There is also another problem: When I press ESC the calculator will stop responding instead of redrawing the normal screen.
What am I missing to make him do so? I can't figure out what makes it work in other programs.
Thanks in advance!
I'm trying to get into c programming for nspire (actually I'm trying to get into c programming at all )
I can have a very simple function, say to draw a dot of 2*2 pixels.
The function works just fine and draws my dot, but when the function is called for a second time the nspire crashes.
Here is the code I use:
Code: [Select]
int main(void) {
clearScreen();
void drawdot(int posx, int posy, int colour) {
setPixel(posx, posy, colour);
setPixel(posx+1, posy, colour);
setPixel(posx, posy+1, colour);
setPixel(posx+1, posy+1, colour);
}
drawdot(10,10,0); //works fine
drawdot(10,15,0); //crashes when I add this line
while (!isKeyPressed(KEY_NSPIRE_ESC)) {}
return 0;
}
There is also another problem: When I press ESC the calculator will stop responding instead of redrawing the normal screen.
What am I missing to make him do so? I can't figure out what makes it work in other programs.
Thanks in advance!