| | |
problem with stacks -in C
![]() |
how to use push and pop here???
thanks!
thanks!
C Syntax (Toggle Plain Text)
#include<stdio.h> #include<stdlib.h> void push(char palindrome[20], int *top, int value) { if(*top<=10) { palindrome[*top]=value; *top++; } else { printf("Stack is full!!"); exit(0); } } int value; void pop(char palindrome[10], int *top) { if(*top>=0) { value=palindrome[*top]; *top=*top-1; } else { printf("The stack is empty!!\n"); } } char palindrome[10]; int top = -1; int value; int x; void main() { clrscr(); printf("Enter word: "); scanf("%s",&value); for(top=0;palindrome[top]!=x;top++) { } top--; for(value=0;palindrome[value]!=x;value++,top--) { if(palindrome[top]!=palindrome[value]) x=1; } if(x==0) { printf("The word you've entered is a palindrome!!\n"); } else { printf("The word you've entered is not a palindrome!!\n"); } getch(); }
•
•
Join Date: Nov 2008
Posts: 32
Reputation:
Solved Threads: 1
Look abby2589 ,
I didn't read all your code but from the general idea of the code i assume that you want to know how to use the stack to check if the word is palindrome or not.
- After you enter the string you will push all of its element from the first character till the end of the string (Using a Pointer ofcourse till the Pointer Reaches NULL).
-Then Pop all the elements from the stack and recieve them in another string.
-And compare the newly created string to the original string that been entered at the first of your program.
I didn't read all your code but from the general idea of the code i assume that you want to know how to use the stack to check if the word is palindrome or not.
- After you enter the string you will push all of its element from the first character till the end of the string (Using a Pointer ofcourse till the Pointer Reaches NULL).
-Then Pop all the elements from the stack and recieve them in another string.
-And compare the newly created string to the original string that been entered at the first of your program.
![]() |
Similar Threads
- C++ Palindrome Problem Help using Stacks (C++)
- need Recursion help (C)
- Stacks - balanced parentheses (C++)
- Runtime error!! ACM problem (C++)
- stack palindrome problem? (C++)
- Data Structure Using JAVA (Java)
- Implementation of Stacks and Queues (C)
Other Threads in the C Forum
- Previous Thread: Mapping Sonar Data with C
- Next Thread: C Compiler Creation
| Thread Tools | Search this Thread |
adobe api array arrays bash binarysearch calculate char cm convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush file floatingpointvalidation fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators intmain() iso kernel kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix microsoft motherboard mqqueue mysql oddnumber odf open opensource openwebfoundation owf pattern pdf performance pointer posix power probleminc program programming pyramidusingturboccodes read recursion recv recvblocked repetition research scanf scheduling scripting segmentationfault send shape socketprograming socketprogramming stack standard string suggestions systemcall test unix urboc user variable voidmain() wab win32api windows.h






