Thread: Reversing a string

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    357
    Quote Originally Posted by Dino View Post
    ... try this string:

    Résumé
    I think it's assumed the strings are composed of ASCII characters (including control characters).
    But the OP din't say so ... so: nice post, Dino!
    Do you have a suggestion on how to deal with your example string?

  2. #2
    Registered User
    Join Date
    Oct 2012
    Posts
    43
    Sorry if I am not too good at this, we just started learning about strings a couple of days ago and our book is quite hard to digest. The entered string is supposed to be a standard sentence from the keyboard such as "Hello world" or "I like pancakes", no special characters and no numbers. I have looked at alot of info online, and most point to doing some kind of for loop but being a beginner with strings I am not sure how to take the hint they gave (copy the string and then start from the back of the string) and implement it into a for loop to reverse the order. I am quite the beginner, so any specific guidance would be great. Thank you all, this is a great forum for people like me

  3. #3
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,337
    If you think about, (well, if I think about it), it's pretty easy.

    A string you get is so long. Create a new variable the same length.
    The first character of the input string goes in the last spot of the new variable
    then, advance one character in your input and subtract one character from your new var, until you have copied strlen(input) characters.

    Dino
    Mainframe assembler programmer by trade. C coder when I can.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. reversing a string, again..
    By Disident in forum C Programming
    Replies: 5
    Last Post: 06-15-2009, 08:01 PM
  2. reversing a string
    By swappo in forum C++ Programming
    Replies: 6
    Last Post: 06-14-2009, 03:18 PM
  3. Reversing a string
    By gandamkumar in forum C++ Programming
    Replies: 16
    Last Post: 11-27-2004, 10:09 PM
  4. Reversing a string
    By michelle1 in forum C++ Programming
    Replies: 12
    Last Post: 06-27-2003, 06:37 AM
  5. Reversing a String
    By ToasterPas in forum C++ Programming
    Replies: 10
    Last Post: 08-14-2001, 12:20 PM

Tags for this Thread