GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 02-Dec-2006, 14:50
limergal
 
Posts: n/a

Help with String Program


Hi, I have a code that I've been working on, and got stuck, I need help in reaching the solution to this program


Program:
This is the program
1)read in one string which consists of two words Ex. "Computer Science"

2)call a function makewords() which receives three parameters: a string which holds the original phrase and two strings to hold the two words.

3)Your function, makewords(), should then check if the 2 new strings are equal to each other, and print the appropriate
message saying whether or not they are equal.

4)print out the two words and their sizes.

5)call the function matchexact() passing the two strings. matchexact() will determine how many times the corresponding positions in the two strings hold exactly the same characters.


For example, if the two strings are "marriage" and "gerbil", then the function matchexact will return 2, since the two strings have the same characters in positions 2 and 5.
If the two strings are "starts" and "tarts", then the function will return 0, since the two strings never have the same characters in the same positions.
The main program will then call a function jointhem() which receives the two strings. The function will join the two strings together and print the new string. Ex. if string1 is “bath” and string2 is “water” than the new string is “bathwater”


CPP / C++ / C Code:
#include<iostream>
#include<string>
using namespace std;

void makewords ( string a, string &b, string &c ) {
    b = a;
    c = "word";
}

int main()
{
    string input="Computer Science";
    string first, second;
    makewords( input, first, second );
    cout << first << endl;
    cout << second<< endl;
    system("pause");
}

  #2  
Old 02-Dec-2006, 17:52
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,310
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Help with String Program


Quote:
Originally Posted by limergal
Hi, I have a code that I've been working on, and got stuck
.
.
.
1)read in one string which consists of two words Ex. "Computer Science"

So: have you done this? I don't see it in your code. Is this where you are stuck?

Quote:
Originally Posted by limergal
2)call a function makewords() which receives three parameters: a string which holds the original phrase and two strings to hold the two words.
OK: I see that you have such a function, but I don't see any attempt to break the string into two words. Is this where you are stuck?

Quote:
Originally Posted by limergal
3)Your function, makewords(), should then check if the 2 new strings are equal to each other, and print the appropriate
message saying whether or not they are equal.
Well, you can't do this until you do step 2
Quote:
Originally Posted by limergal
4)print out the two words and their sizes.
Ditto
Quote:
Originally Posted by limergal
5)call the function matchexact() passing the two strings.
I don't see this. Is this where you are stuck?


If you would tell us what part you would like some help with, I'll bet that someone can come up with some suggestions.

Regards,

Dave
  #3  
Old 03-Dec-2006, 09:10
admin's Avatar
admin admin is offline
Administrator
 
Join Date: Sep 2002
Posts: 858
admin will become famous soon enough

Re: Help with String Program


Thank you for your reply Dave but limergal wrote in to request that we delete her account. She made the request BEFORE you replied.
__________________
Custom BB codes you can use here:
[HTML] | [C++] | [CSS] | [JAVA] | [PY] | [VB]
  #4  
Old 03-Dec-2006, 09:30
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,310
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Help with String Program


Quote:
Originally Posted by admin
limergal wrote in to request that we delete her account

My response was only a couple of hours after the Original Post. Thanks for telling me that the Original Poster cancelled before I replied. I might have thought there was a problem with something that I said or the way that I said it.

I'm sorry that I couldn't help. Since there is nothing useful about programming or problem solving, maybe you should delete the entire thread???

Regards,

Dave
  #5  
Old 03-Dec-2006, 09:34
admin's Avatar
admin admin is offline
Administrator
 
Join Date: Sep 2002
Posts: 858
admin will become famous soon enough

Re: Help with String Program


I was going to delete the thread but I was certain someone was going to reply and I didn't want them to have wasted their time.

If you think what you wrote is of no value to any one else, then I will delete the thread. I will do this tomorrow.
__________________
Custom BB codes you can use here:
[HTML] | [C++] | [CSS] | [JAVA] | [PY] | [VB]
  #6  
Old 03-Dec-2006, 09:40
admin's Avatar
admin admin is offline
Administrator
 
Join Date: Sep 2002
Posts: 858
admin will become famous soon enough

Re: Help with String Program


By the way, I have no problems leaving this thread as is. I will simply move our off-topic discussions out of the way.

When senior members post in a thread, I hate to delete these threads. You guys are genuinely trying to help out other people and I can imagine that you at least put some thought (and effort) into your replies. For that reason alone, I think we should keep it.
__________________
Custom BB codes you can use here:
[HTML] | [C++] | [CSS] | [JAVA] | [PY] | [VB]
  #7  
Old 03-Dec-2006, 14:47
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,310
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Help with String Program


Quote:
Originally Posted by admin
By the way, I have no problems leaving this thread as is. I will simply move our off-topic discussions out of the way.

When senior members post in a thread, I hate to delete these threads. You guys are genuinely trying to help out other people and I can imagine that you at least put some thought (and effort) into your replies. For that reason alone, I think we should keep it.

I don't care (much) either way. If you think it adds value to the board, it's OK by me (edit/crop as you like).

If future potential posters see the futility of posting a request for help that doesn't give us anything on which we can base a helpful response, it's worth keeping.

But the potential future posters who could possibly gain some insight from this probably don't go through the board and look at old threads anyhow. At least that's my impression --- but I could be wrong (again).

Regards,

Dave
 
 

Recent GIDBlogInstall Adobe Flash - Without Administrator Rights by LocalTech

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
help with survey program shaffer C++ Forum 5 01-Dec-2006 08:51
Message Class TransformedBG C++ Forum 5 29-Nov-2006 21:28
i need help with a string program!!! betazee C Programming Language 3 05-Jun-2006 22:44
Type casts ? kai85 C++ Forum 12 23-Jun-2005 12:04
Help wit my source code compiler errors Krandygrl00 C++ Forum 1 06-Jun-2005 08:14

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 14:14.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.