   Append data to a string
  Here's an easy couple of questions for ya!I have two character arrays, myStr[1024] and moreData[128].myStr[] already contains some data:Hello, world!\nHow are you?\nmoreData[] contains this data:I'm fine!\nWhat's an easy way to append moreData[] to the end of myStr[]?  I want myStr[] to end up reading like this:Hello, world!\nHow are you?\nI'm fine!\n---------------------------------Here's my other question...In this scenario, myStr[] is almost full.  The contents of moreData[] is going to overfill myStr[] if I simply append to it.  How do I 'roll off' the old data in myStr[] so I can continuously stream new data into it?Thanks in advance for the help! [smile]   
  Hey mate,use strcat() in C;use stringstream in C++;std:stringstream mySS;mySS << myStr << moreData;string fullString = mySS.str();Ofcourse +'ing strings together works too.Hope that helps,Dave   ;  Assuming C++, you should use std::string instead of raw char arrays. Then concatonating strings becomes string1 + string2.   ;  Don't. Use std::string:#include <string>#include <iostream> // for the example belowint main(){    std::string s="hello";    s+=" world";    const char *ptr=s.c_str(); // if you need a char * pointer for anything    // although - you shouldn't store the pointer like this since it can    // become invalid. Perhaps a better example would be    std::ifstream is(s.c_str());    // which requires a const char* arguement so won't accept a string    // directly    is.close();    return 0;}If you are not using C++, the only way to prevent the overflow would be to reallocate the memory. If you have allocated like:char s[30];then you can't. You would need to dochar *s=(char*)malloc(30);then when you wanted to make it bigger:char *temp=s;s=(char*)malloc(100);strcpy(s,temp);free(temp);This is the old C way of doing things and as you can see is a raving nightmare, hence the advantage of using C++ and the existing std::string type which takes care of all this for you.HTH[EDIT] I just knew that was going to be too slow [smile].   ;  Thanks for the tips, guys!  I'll give it a go when I get home later today (I'm currently at school).Looks like I'm just gonna have to sit down and knuckle down on my C++...  I learned C by modding the Quake3 game for years, so all I know is old-school C programming (which works fine in my Visual C++ .net environment).Thanks again!   