![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Feb 2005
Posts: 2
Rep Power: 0
![]() |
inserting text into a string
Hi everyone.
Can someone give me an idea as how to insert text into the middle of a string in C or C++? I want to implement a simple find and replace function, that searches a string for a specified substring, and replaces it with another which could be of a different length. Im really scratching my head on this one ![]() |
|
|
|
|
|
#2 |
|
Programmer
|
The string.h library has quite a few functions for dealing with strings - you can search strings for specific characters or even substrings, replace chars or substrings etc...
A description of all these functions is here.
__________________
~ You know, Hobbes, some days even my lucky rocketship underpants don't help. ~ read my blog @ My Lucky Rocketship Underpants
|
|
|
|
|
|
#3 |
|
Programming Guru
![]() ![]() ![]() |
The Standard Template Library is also a good source for such things... no need to reinvent the wheel.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#4 |
|
Expert Programmer
|
Yeah man, just go with STL... that is what it is there for... you could spend at least a good week writing a good string class and functions that even come close to doing what STL's string class can.
__________________
Clifford Matthew Roche <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Feb 2005
Posts: 2
Rep Power: 0
![]() |
OK thanks guys I'll have a look at STL.
![]() |
|
|
|
|
|
#6 |
|
Professional Programmer
Join Date: Feb 2005
Location: PA, USA
Posts: 253
Rep Power: 4
![]() |
check this link out, i believe this is what you are looking for
String Members basically, it's a list of all the member functions and what they do for the string class. check out the "Insert" member. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|