reverse string without using strrev() function

This is a discussion on reverse string without using strrev() function within the C Programming forums, part of the General Programming Boards category; any idea to reverse string without using strrev() function in C? *Just only use stdio.h to complete scoure code Thank ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    3

    reverse string without using strrev() function

    any idea to reverse string without using strrev() function in C?
    *Just only use stdio.h to complete scoure code

    Thank you for your idea ^^

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,827
    Well, there is no strrev() function in the C standard library in the first place

    Use or replicate strlen() to find the length of the string, and then swap the corresponding nth and (length - n - 1)th chars in a loop that stops halfway through the string.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    3
    Erm,can give some example?i didn't understand what u try to explain. XD

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So how much of it DO you understand. Can you read a string? Can you figure out it's length? Do you understand how to get the nth character out of a string?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 10:03 PM
  3. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  4. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  5. C function to reverse a given String!!
    By Unregistered in forum C Programming
    Replies: 10
    Last Post: 07-18-2002, 10:35 PM

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