When I printed it I got error like this 17:1733╠╠╠╠╠╠╠╠17:╠╠
.
I couldn't figure it out. I would appreciate if you solve and give me a better approach? Thanks for your help.
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <cstdlib>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
char* time = "173324";
char holdh[3];
char holdM[3];
char holds[3];
holdh[2] = '\0';
holdM[2] = '\0';
holds[2] = '\0';
int t;
for (t = 0; t < 6;t++)
{
if (t < 2)
holdh[t] = *(time + t);
else if (2 <= t < 4) {
t = t - 2;
holdM[t] = *(time + t);
t = t + 2;
}
else if (4 <= t < 6)
{
t = t - 4;
holds[t] = *(time + t);
t = t + 4;
}
}
string h(holdh);
string M(holdM);
string s(holds);
string datex = h + ":" + M + ":" + s;
cout << datex;
return 0;
}
It might be overflow of memory but I tried to prevent that by assigning null
values. So if I have a problem in there too please inform. Thanks again.