Thread: string reverse(stack mode)

  1. #1
    Notorious Turbo C killer blacksnake's Avatar
    Join Date
    Jan 2007
    Location
    philippines
    Posts
    50

    Question string reverse(stack mode)

    i was trying to plan on string reverse by open a file and read the content of the file...but I have a code for reading and writing the file...in reversing the content of the file, i already have a array mode or strrev()...but the question is how to reverse the content of the file using stacks...?

    my ingredient for this program is a file IO in c, and the file...but problem is that program uses stack implementation? how is it worked?

    i hope it will reply soon
    Turbo C Makes me Sick....i just want to learn data structures in latest c++

    Le Tormente (fr. the torment)

  2. #2
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,732
    The first question which i need to ask is

    Do u know how the stack works. If not you need to go through it and understad how it works

    But here is a brief description.

    Code:
    1. Start reading every word from the file. 
    2. Push the read word on to the stack. 
    3. Read the step 1 and 2 till you reach EOF
    4. Come reached EOF. Pop  the work which is on top of the stack
    5. Print word.
    This way you can reverse the over all file. And for your function don’t use strrev function, that’s not a standard function

    Ssharish2005

  3. #3
    Notorious Turbo C killer blacksnake's Avatar
    Join Date
    Jan 2007
    Location
    philippines
    Posts
    50
    Quote Originally Posted by ssharish2005 View Post
    The first question which i need to ask is

    Do u know how the stack works. If not you need to go through it and understad how it works

    But here is a brief description.

    Code:
    1. Start reading every word from the file. 
    2. Push the read word on to the stack. 
    3. Read the step 1 and 2 till you reach EOF
    4. Come reached EOF. Pop  the work which is on top of the stack
    5. Print word.
    This way you can reverse the over all file. And for your function don’t use strrev function, that’s not a standard function

    Ssharish2005
    how to elaborate such description?
    Turbo C Makes me Sick....i just want to learn data structures in latest c++

    Le Tormente (fr. the torment)

  4. #4
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,732
    Sorry that was my poor explaination. The description which is given above is not a description rather u can think it off as an puesudo code. I order to implement that u need to understand stack mechanism.

    Here is a good link for that Stacks

    After reading the working on stack u will undertstand the algorithm which i have given there up.

    ssharish2005

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. char Handling, probably typical newbie stuff
    By Neolyth in forum C Programming
    Replies: 16
    Last Post: 06-21-2009, 04:05 AM
  2. Inheritance Hierarchy for a Package class
    By twickre in forum C++ Programming
    Replies: 7
    Last Post: 12-08-2007, 04:13 PM
  3. RicBot
    By John_ in forum C++ Programming
    Replies: 8
    Last Post: 06-13-2006, 06:52 PM
  4. lvp string...
    By Magma in forum C++ Programming
    Replies: 4
    Last Post: 02-27-2003, 12:03 AM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM