473,387 Members | 1,541 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,387 software developers and data experts.

How do I fix the function string?

This is what I have so far:
Expand|Select|Wrap|Line Numbers
  1.  
  2. // This program changes 'the' to 'that'
  3. #include <iostream>
  4. #include <string>
  5. using namespace std;
  6.  
  7. // Function prototype
  8. void replaceSubstring(string1, string2, string3);
  9.  
  10. int main ()
  11. {
  12.    // Define three string objects.
  13.    string string1, string2, string3;
  14.  
  15.    // Assign values to all three.
  16.    string1 = "the dog jumped over the fence";
  17.    string2 = "the";
  18.    string3 = "that";
  19.  
  20.    return 0;
  21. }
  22.  
  23. //************************************************************
  24. // Definition of the replaceSubstring function. This function*
  25. // searches the strings for 'the'.                           *
  26. //************************************************************
  27.  
  28. void replaceSubstring(string1, string2, string3)
  29. {
  30.    string1.find('the');   // Find 'the'
  31.          string1.insert("that");
  32.    }
  33.  
I am trying to replace all instances of 'the' with 'that'. I know it should be fairly simple, but for some reason, I need some help.

Also, do any of you experience peculiar program errors when running Microsoft Visual Basic? I've had to reinstall mine several times...

Thanks in advance.
Nov 24 '10 #1
3 1601
Banfa
9,065 Expert Mod 8TB
Start by declaring it correctly. The most basic text books or C++ tutorials should show examples of calling a function with parameters.

You need to give the parameter type and optionally the parameter name.
Nov 24 '10 #2
whodgson
542 512MB
There are aspects of the code posted that look uncommonly like VB
e.g. string1.find('the'); // Find 'the'
string1.insert("that");
Nov 25 '10 #3
Banfa
9,065 Expert Mod 8TB
Your not up on your std::string C++ STL class, it has both of those methods :D
Nov 25 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Filip Dreger | last post by:
Each function has a func_code property that is suposed to contain the pure bytecode of the function. All the context (including reference to relevant namespaces) is stored in different fields of...
2
by: Al Bondy | last post by:
Hi, I'm trying to use the XSL function string-join() as explained at the following link : http://www.w3.org/TR/xpath-functions/#func-string-join Here is my line of code <xsl:value-of...
4
by: higabe | last post by:
Three questions 1) I have a string function that works perfectly but according to W3C.org web site is syntactically flawed because it contains the characters </ in sequence. So how am I...
9
by: Kishor | last post by:
Hi all, I am Using VB.Net for developing my application. I am now needed help. In this project I have to execute some function, but I cannot call them directly using function name, I wanted to...
10
by: KJ | last post by:
Hello, Why does this not work? txtMoney.Text.Format("#,##0.00") If I type 100 in txtMoney, it returns #,##0.00 I have never gotten the format function to work in .NET.
1
by: Wally | last post by:
Is there in VB NET something like the old Vb6 STRING$() function? Thanks. VV
6
by: Uwe Grawert | last post by:
I have the following recursive function: string find_value_by_key (xmlDocPtr doc, xmlNodePtr root_node, const string& key) { while(root_node != NULL) { if(! xmlStrcmp( root_node->name,...
16
by: recover | last post by:
#include <string> #include <iostream> using namespace std; class TConst { private: string con; string uncon; public:
2
by: rn5a | last post by:
All the String functions like 'Len', 'Left', 'Right', 'Mid' etc. that are available in ASP are supported by ASP.NET as well except for the string function 'String'. The 'String' function takes...
3
by: MrHenry007 | last post by:
Hello! I'm fairly new to c++ but I have been following tutorials and have created functions before, but not one using a string. I can't work out what the problem is here. The function is supposed...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.