Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,694 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,339 people online right now. Registration is fast and FREE... Join Now!




string manipulation

 
Reply to this topicStart new topic

string manipulation, adding in a full stop

tootypegs
post 4 Sep, 2008 - 11:06 AM
Post #1


D.I.C Head

**
Joined: 9 Oct, 2007
Posts: 177


My Contributions


hi, basically i am stuck with something that seems extremely simple but i just cnt figure it out. Say i have the string:

'mypicjpg'

I would like to add in a fullstop (.) 3 letters from the end of the string. is there some form of string manpulation i can use to add this in?

thanks
User is offlineProfile CardPM

Go to the top of the page

gabehabe
post 4 Sep, 2008 - 11:25 AM
Post #2


Working Girl.

Group Icon
Joined: 6 Feb, 2008
Posts: 5,442



Thanked 94 times

Dream Kudos: 2625

Expert In: ruling the world.

My Contributions


1) You could use string.insert()
2) Specifically 3 characters away from the end. To get to this position, you would want to do something like this: myStr.length() - 3;

So, let's add those two together, along with the . that we want to add to the string:
myStr.insert((myStr.length() - 3), ".");

note that this is C++

Hope this helps smile.gif


EDIT:
teehee, you drew a boob:
QUOTE(you)
(.)
laugh.gif
User is online!Profile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/23/08 07:50AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month