String concatenation

Hi,

I want to create an C++ program for "String concatenation using dynamic memory allocation concept". Please any one send me a sample code for this.



Thank You

Nancy
Typically on these forums we don't give free code for homework solutions. see the first post on the forum for an explanation why. Being a programmer is about problem solving if we simply give you code then the only way we are helping you is 1# helping you look good in front of your teacher, 2# helping you pass your subject.

However most find the view that 3# helping you become a programmer is far far more important. which is why we don't dump code on people.

I have a fairly good idea what the answer should be, However what do you think it means by dynamic memory allocation?
and can you explain what "string concatenation" means?

Last edited on
Hi Gcampton,

Actually , i have to implement the c++ program using dynamic memory allocation concepts fo string concate (for example :
if string1="new" and string2="york" then display the string3=newyork") in these example i have to implement with dynamic memory allocation.

But i dont know memory allocation concept.


Thank you

nancee
first you need to know pointer so read this is you don't know what is a pointer
http://cplusplus.com/doc/tutorial/pointers/

then move on and read dynamic memory allocation
http://cplusplus.com/doc/tutorial/dynamic/

work on it then post what you've done.. we'll try to help if you got into a problem..
I'm assuming you have been learning about arrays in the last week, or few weeks. Have a read of this: http://www.cplusplus.com/doc/tutorial/dynamic/

Basically what I think you are required to do is create string array dynamically and then concatenate each element to create a larger string. Have a go at starting to write this after reading the above link. Then we can discuss any problems you encounter.

edit: too slow :P
pointers are not necessarily needed, you can do this with just arrays if you have not yet learned about them, it's probably better to concentrate on 1 topic at a time. Move on to learning about pointers after you have accomplished this.
Last edited on
Topic archived. No new replies allowed.