Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

adding a letter to a string at any position???

I have a string lets say "home", and I want to add a letter 'a' to that string at second position so that the new string would be "hpome". How can I insert a character to a string at any position???

Thanks.
0
gjgomez
Asked:
gjgomez
1 Solution
 
Jaime OlivaresSoftware ArchitectCommented:
Will be easy with a STL string and insert function:

    std::string s = "home";
    s.insert(1,"a");
    cout << s << endl;    
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now