I am creating a time class (string base) for my school project! I get a pointer character for the time!I have a function to normalize the time if it is weird.
in normalize function I have a character array to store the correct time but when I want to Assign the character array to the pointer character it is going false!
char st[10] = "", sh[3] = "", sm[3] = "", ss[3] = "";
itoa(hour, sh, 10);
itoa(minute, sm, 10);
itoa(second, ss, 10);
if(hour<10){strcat(st, "0");}
strcat(st, sh);strcat(st, ":");
if(minute<10){strcat(st, "0");}
strcat(st, sm);strcat(st, ":");
if(second<10){strcat(st, "0");}
strcat(st, ss);strcat(st, "");
stime = st;
stime is pointer character which save the time in class.
when I want to use value of stime I get very weird result. stime get the value of last class stime. for example I have this code:
time a("1:50:0"), b("4:5:10");
a.print();
b.print();
but I get 04:05:10 for two classes and I don't know why!
If you need the rest of code I upload it here: Google Drive link to file
std::stringplease when programming in c++. This makes my eyes bleed.g++.