473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

hello again..

hello again..
i want to design a program which takes in a string and replaces all 's'
characters with 'sh'. how do i do it? thanks a lot!

Oct 8 '06 #1
2 1512
In article <11*********************@i3g2000cwc.googlegroups.c om>,
hk**********@hotmail.com wrote:
hello again..
i want to design a program which takes in a string and replaces all 's'
characters with 'sh'. how do i do it? thanks a lot!
#include <cassert>
#include <string>

void replace( string& line, const string& from, const string& to )
{
// insert code here.
}

int main()
{
string myString = "s";
replace( myString, "s", "sh" );
assert( myString == "sh" );
}

Insert code at the spot that says "insert code here" until the program
exists without the assert aborting it.

--
There are two things that simply cannot be doubted, logic and perception.
Doubt those, and you no longer*have anyone to discuss your doubts with,
nor any ability to discuss them.
Oct 8 '06 #2
Daniel T. wrote:
>hello again..
i want to design a program which takes in a string and replaces all 's'
characters with 'sh'. how do i do it? thanks a lot!

#include <cassert>
#include <string>

void replace( string& line, const string& from, const string& to )
{
// insert code here.
}

int main()
{
string myString = "s";
replace( myString, "s", "sh" );
assert( myString == "sh" );
}

Insert code at the spot that says "insert code here" until the program
exists without the assert aborting it.
Then add these lines to main():

string myString = "is";
replace( myString, "s", "sh" );
assert( myString == "ish" );

And add more code, until this test passes too. Repeat until the tests cover
a sample of all permutations, such as "nada", "sis", "its", and so on.

--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
Oct 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Niklas Borson | last post by:
Hi gurus! I'm a C++ newbie and I've heard that a good first program is one that prints "Hello World!" I tried typing in a program I found in a book, but for some reason it wouldn't compile. So I...
4
by: Roy Yao | last post by:
Why the following code let my compiler complain an overloaded function Init()? // code begin template<class T> class BicircularList { template<class T> class Iterator; template<class T> class...
26
by: Santanu Chatterjee | last post by:
Hello all, I would like to know how an OS makes a computer boot up. For that, as a start I would like to see an e_ample (read the underscore as the letter before y, as the keyboard here is...
7
by: Calvin KD | last post by:
Hi everyone, Has someone out there experienced the same problem? What i wanted to do is to display a popup window (modal) upon the loading of a webpage. Here is my code sample (in html view):...
1
by: John Thompson | last post by:
Hello, I recently developed the hello world web service in Visual Studio 2005. If I right-click on the Service.asmx file that is created, everything works fine in Visual Studio. After...
10
by: fei.liu | last post by:
Consider the following sample code char * ptr = "hello"; char carray = "hello"; int main(void){ } What does the standard have to say about the storage requirement about ptr and carray? Is...
3
by: salvadorvp | last post by:
Hi, here I have a very simple 'hello world' example that makes use of Yahoo! User Interface Library. I have a problem with my response string coming back as ''. I managed to check that everything...
14
by: Vasu | last post by:
Hi ! Out there, anybody could help tell me what could be the reason that my php scripting is not giving output in IE6. Which I'm trying from my webserver itself, having IIS 5 on W2k Advanced...
10
by: lvl 1 monk | last post by:
Hi all, I don't really have the money for the formal route so I went to the library and picked up an older c++ book and it seems I run into "antiquated headers" over and over again. The problem...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.