Search
 
SCRIPT & CODE EXAMPLE
 

C

stack push code

/* 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 
");
        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;
}
Comment

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 
");
        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;
}


Comment

Stack Push

int push(int data) {

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

PREVIOUS NEXT
Code Example
C :: how to print in c 
C :: putchar in c 
C :: typescript class as function parameter 
C :: C Arithmetic Operators 
C :: c read n bytes code 
C :: grepper vscodium 
C :: bitwise and in c 
C :: how i send custom data in model field rest_framework serializer 
C :: bootstrap 4 forms 
C :: arrays in c 
C :: passing two dimensional array to function in c 
C :: windows forms picturebox change image 
C :: gcd and lcd in c 
C :: string array in c 
C :: c median of array 
C :: #0000ff 
C :: empiler une pile on c 
C :: pointer arithmetic on Arrray in c 
C :: how to arrange a 2d array based on string length in c 
C :: Relational Operator in C language 
C :: armstrong in c 
C :: english to russian translation 
C :: *= operator 
C :: c atoi atof 
C :: Highest integer among the four inputs in c 
C :: c program for fibonacci series 
C :: Battlefield4u.com 
C :: translator program in c 
C :: Handling exceptions during datetime conversion 
C :: uri/beecrowd problem no - 1133 solution in C 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =