void keyPressed(char key) { //the clear button if (key == 'C') { clear(); _log("lcd cleared\r\0"); return; } // switch (state) { case 0: if ((value=getDigit(key)) != -1) //digit {_log("number\r\0") //check stack, if full show errer if (! stack_isfull(sd1)) { stack_push(sd1,value); LCD_SendData(key); } else { showError(); _log(" stack full\r\0"); } } else if(getOperator(key) != -1) //operator
static void push(const double value){ if( stack == 0 ){ bailout("push Stack is not initialized"); } if( stack_isfull() == TRUE ){ bailout("push Stack is full"); } stack->esp[stack->actsize] = value; stack->actsize++; }
int stack_push(stack_t *stack, int value) { if (stack_isfull(stack)) return -1; stack->data[stack->top++] = value; return 0; }
int stack_push(void *data, STACK *handle) { if (stack_isfull(handle)) return -1; memcpy(handle->data + handle->end * handle->size, data, handle->size); handle->end++; return 0; }
static void montar_caminho(struct bstree *tree, struct bstree *destino) { if (tree != NULL) { if (stack_isfull(caminho)) { char last = stack_pop(caminho); caminho = stack_free(caminho); caminho = stack_new(MAX_CAMINHO); stack_push(caminho, (int) last); } stack_push(caminho, token_para_simbolo(tree->value->token)); if (tree == destino) { imprimir_caminho(); return; } montar_caminho(tree->lchild, destino); montar_caminho(tree->rchild, destino); //(void) stack_pop(caminho); } }
void stack_push(struct stack *s, int element) { assert(!stack_isfull(s)); s->arr[++s->top_index] = element; }