示例#1
0
文件: stack.c 项目: TerraPi/VM
void push(stackT *stackP, stackElementT element){
	if(fullStack(stackP)){
		fprintf(stderr, "Can't push element on stack: stack is full. \n");
		exit(1);
	}
	stackP->contents[++stackP->top] = element;
}
示例#2
0
///********************************
///Function: push
///Task: if the stack is not full, increments the topIndex int and adds an element to the top of the stack
///Returns: nothing
///********************************
void calcStack::push(double number)
{
    if (isFull())
    {
        throw fullStack();
    }
    topIndex++;
    nums[topIndex] = number;
}
示例#3
0
int push(struct Stack *stack, long data)
{
	if (fullStack(stack)) {
		fprintf(stderr, "%s", "\nfull stack!\n");
		return -EFULLSTACK;
	}

	stack->stack[stack->sp++] = data;

	return 0;
}