/* 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;
}
/* 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;
}
int push(int data) {
if(!isfull()) {
top = top + 1;
stack[top] = data;
} else {
printf("Could not insert data, Stack is full.
");
}
}
Code Example |
---|
C :: program to find the average of n numbers using arrays. |
C :: c bubble sort |
C :: do...while loop c |
C :: how to get the lowest number on a array in c |
C :: addition of matrix |
C :: unsigned char c programming |
C :: set the nth bit |
C :: C program for float division of numbers |
C :: function component with props |
C :: pygramid program in c |
C :: to execute a program using C |
C :: chevront de vlavier |
C :: c memcpy |
C :: getline() in c |
C :: vifm preview images |
C :: int to void* c |
C :: passing pointer to function |
C :: loops questions on c |
C :: c malloc |
C :: fungetc |
C :: how to check file pointers in c |
C :: run a command in cmd with c |
C :: c to assembly online compiler |
C :: BST or NOT ?? |
C :: send data to port in c |
C :: c math.h sqrt |
C :: Reverse every Word of given String |
C :: variadic macros in c |
C :: Example of header file c |
C :: levenshtein c |