I'm just starting C++, and I need help with a something....
How can I concatenate numerical data (integers/longs) to string values??
I've tried some things but nothing works..
Thanks in advance for any help..![]()
This is a discussion on help a newbie :( within the C++ Programming forums, part of the General Programming Boards category; I'm just starting C++, and I need help with a something.... How can I concatenate numerical data (integers/longs) to string ...
I'm just starting C++, and I need help with a something....
How can I concatenate numerical data (integers/longs) to string values??
I've tried some things but nothing works..
Thanks in advance for any help..![]()
~void
Code:char * l_strcat( char str[], long my_long) { char temp[MAX]; sprintf(temp, " %Li ", my_long); return strcat(str, temp); }
Code:int main(void){srand(time(0));for(double l=rand(),l0=0,l00=0;;l0+=0.1){for(double l000=0;l000 <1;l000+=.001,l+=((double)rand()/RAND_MAX)/0x64,l00+=((sin(l*0x8*atan(l0)*l000-(l0*0x8*atan (l)))*0.5)+0.5)){l00-=floor(l00);for(size_t l0000=0,l00000=(size_t)(0x50*(l00));l0000<l00000;++l0000 )putchar(0x20);putchar(0x61+(int)((double)rand()/RAND_MAX*0x1a));putchar('\n');}}return 0;}
I'll try then:
Code:template<typename T> void mystrcat(std::string& str, T t) { std::stringstream sout; sout << str << t; str = sout.str(); } int main() { using namespace std; string p = "Sang-drax"; mystrcat(p,123); cout << p; }
Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling