hi frieandz I am chaitanya, I am new to this forum, well I am posting my first thread to this forum, please reply to this with an answer,
I got a string called "helloworld" I want to swap the two words in that string an di want to print it as "wolrdhello",
can any one give me a simple logic to this,
thank you
with regards
chaitanya
chaitanya.b
0
Newbie Poster
Recommended Answers
Jump to PostLike This
#include <iostream> #include <string> using namespace std; int main () { string str="HelloWorld"; string first=str.substr(0,5); string second=str.substr(5,5); cout<<str;//Original String str=second+first; cout<<endl<<str;//Swapped String return 0; }
All 4 Replies
SpS
34
Posting Pro
chaitanya.b
0
Newbie Poster
SpS
34
Posting Pro
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.