I am trying to concatenate multiple strings but the result is incorrect. Here is what I have:
This is date, time (i.e. 2012-04-25 19:26:12). I would like to attach "20" in front of the date to make it a whole 2012 and remove seconds from the end of the time and concat both strings to get something like this:
Finally, I would like to put keyword "date" in front of it and run it with "system" command. I have the following code that kinda works but I get a weird character at the end:
string str = "3784491,-12229083,120425,194649"; string dt = str.substr (18,6); string tm = str.substr (25, 6); char d; strcat (d, "20"); strcat (d, dt.c_str()); strncat (d, tm.c_str(), sizeof (tm)); cout << d << endl; d='\0'; char a = "date "; a = '\0'; cout << a << endl; char po; strcat (po, a); strcat (po, d); po = '\0'; cout << po << endl;
This is the output I get:
I don't understand where the "(" comes from?! Am I missing something?
Any help would be appreciated