![]() |
function which returns union of two strings
Code:
#include <string>I need help from you. I try to write the code in C++ which return union of two strings , This is the code, if you know how to write the right code please help me... |
Re: function which returns union of two strings
This function doesnt return anything, you must use "return" .
|
Re: function which returns union of two strings
Could you fix code, it is really important for me. thank you for your time
|
Re: function which returns union of two strings
Quote:
Quote:
|
Re: function which returns union of two strings
Quote:
BTW. you can use function strcat() for concatenating strings together, unless you wanted to do it literally your own way without using any preprogrammed functions. |
Re: function which returns union of two strings
Hey, good daddy has come to you! I took a closer look on your function and I tried to compile your code. The output was good, it returned "123456".
POC: http://postimage.org/image/fuae7joij/ |
Re: function which returns union of two strings
Quote:
Have you figured out how to do it on paper? Cos if you can't do it yourself, then there's no way you'll be able to program a computer to be able to do it. BTW to the other poster, strcat won't do the trick; the task is to return the *union* of the strings. Think back to set theory. So the union of "123" and "345" is "12345", not "123345" which would be the strcat result. |
Re: function which returns union of two strings
Hi
I bothered to read your program and corrected a few things. I hope that you read my program carefully and learn from it. I hope that it is not your homework. Best regards Chong Code:
|
Re: function which returns union of two strings
This code works, but does not work for this example:
string1 = " rry" string2 = " yoh" result is string3 =" rryoh" The result should be ryoh, not rryoh. This code does not check different letters from first string, just for second. Can you help me how to solve that? |
Re: function which returns union of two strings
By "help you solve it" do you mean "write it for you"? Me: no, but you might be able to get some other mug to do your homework for you. But where are you stuck? What have you tried? You can probably solve this by guessing. Try solving it a few times on paper, and then try describing (to a friend, or a dog, or the wall - whatever works) how you do it, and why you choose whether or not to include a character in the result, and see if you can derive an algorithm from that.
|
| All times are GMT +5.5. The time now is 04:35. |