How to output tokens in reverse order using strtok

This is a discussion on How to output tokens in reverse order using strtok within the C++ Programming forums, part of the General Programming Boards category; I just need a hint on how to reverse a list of tokens from a srting after strtok has been ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    1

    How to output tokens in reverse order using strtok

    I just need a hint on how to reverse a list of tokens from a srting after strtok has been used. This is what the orginal problem looked like but i just needed help with this one aspect:
    Write a program that inputs a line of text, tokenizes the line with function strtok and outputs the tokens in reverse order.

    Your help would be tremendously appreciated!

    Yours sincerely
    Ninz

  2. #2
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    Seems like homework to me....make an effort..then post code. Then we'll help
    PHP and XML
    Let's talk about SAX

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    What did you do with all those pointers returned by strtok() as you were making your way through the array?
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    You could use an std::stack and push each token on then print before you pop them off...
    Example
    Code:
    edit: Homework eh..

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Sounds like a nice one for recursion too
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. i want to print my linked list in the reverse order please help
    By raghu_equinox in forum C Programming
    Replies: 9
    Last Post: 10-14-2006, 12:45 AM
  2. How do you order your game code?
    By Queatrix in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 02-05-2006, 05:26 PM
  3. Need help fixing bugs in data parsing program
    By daluu in forum C Programming
    Replies: 8
    Last Post: 03-27-2003, 05:02 PM
  4. Control different DA output value!
    By Hunterhunter in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 03-13-2003, 11:11 AM
  5. Parsing and Tokens (strtok)
    By readerwhiz in forum C Programming
    Replies: 6
    Last Post: 04-22-2002, 09:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21