Horje
Stack Push Code Example
Stack Push
/* Function to push an item to stack*/
void push(struct sNode** top_ref, int new_data)
{
    /* allocate node */
    struct sNode* new_node = (struct sNode*)malloc(sizeof(struct sNode));
    if (new_node == NULL) {
        printf("Stack overflow \n");
        getchar();
        exit(0);
    }

    /* put in the data */
    new_node->data = new_data;

    /* link the old list off the new node */
    new_node->next = (*top_ref);

    /* move the head to point to the new node */
    (*top_ref) = new_node;
}


Stack Push
int push(int data) {

   if(!isfull()) {
      top = top + 1;   
      stack[top] = data;
   } else {
      printf("Could not insert data, Stack is full.\n");
   }
}




C

Related
how to login to another user in powershell Code Example how to login to another user in powershell Code Example
how to replace a number in an array in the console for c programming Code Example how to replace a number in an array in the console for c programming Code Example
c bit access union Code Example c bit access union Code Example
shuffle function in c Code Example shuffle function in c Code Example
How to define Max in define in c Code Example How to define Max in define in c Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9