LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-29-2005, 09:18 PM   #1
Artimus
Member
 
Registered: Feb 2003
Location: Wisconsin
Distribution: Slackware
Posts: 188

Rep: Reputation: 30
C++ function to write text backwards?


I'm looking for a way to take some text and flip it around backwards. An example:

It takes the word "APPLE". I want it to switch it to "ELPPA". It'd be good for it to be a function.

Thanks
-Artimus

P.S. Google didn't turn up anything. The only thing I found was in Javascript.
 
Old 06-29-2005, 09:45 PM   #2
carl.waldbieser
Member
 
Registered: Jun 2005
Location: Pennsylvania
Distribution: Kubuntu
Posts: 197

Rep: Reputation: 32
Code:
#include <iostream>
#include <string>
#include <algorithm>

int main() 
{
 std::string s("APPLE");
 std::reverse(s.begin(), s.end());
 std::cout << s << "\n";

 return 0;
}
"The C++ Standard Library A Tutorial and Reference" by Nicolai M. Josuttis. Probably one of the most useful C++ books in my collection.

If you find youself without the book handy, a good web reference is http://www.sgi.com/tech/stl/.
 
Old 07-01-2005, 09:18 AM   #3
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
you doing people's homework for them carl
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using c++ to write to a text file. Im having problem with strings swatward Programming 4 02-03-2005 09:17 PM
pasting swedish text from openoffice write to kile martine Linux - Software 1 11-25-2004 04:40 AM
Write own stat() function... indian Programming 1 09-14-2004 07:06 AM
php script can not write text file lemotion Linux - Newbie 5 04-20-2004 10:14 PM
write function cxel91a Programming 4 01-15-2004 11:09 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration