| | |
problem with stacks -in C
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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 |
Tag cloud for C
#include * append array arrays asterisks binarysearch calculate changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc database directory dynamic execv feet fflush fgets file fork forloop framework function getlasterror givemetehcodez grade gtkwinlinux hacking histogram inches include incrementoperators input intmain() iso kernel keyboard km license linked linkedlist linux list lists locate logical_drives looping loopinsideloop. lowest matrix microsoft motherboard mqqueue number oddnumber odf opendocumentformat opensource overwrite owf pattern pdf performance pointer posix problem probleminc process program programming radix recursion recv recvblocked research reversing scanf scripting segmentationfault sequential socket socketprograming standard string structures systemcall testing threads turboc unix user variable voidmain() wab whythiscodecausesegmentationfault windowsapi






