I made a function that would allow me to get the current date and put it on a string in YYYY.MM.DD format.
string Date::getCurrentDate(){
char datenew[8];
char currentdate[8];
string s;
int size;
_strdate(datenew);
currentdate[0]=datenew[6];
currentdate[1]=datenew[7];
currentdate[2]=datenew[5];
currentdate[3]=datenew[0];
currentdate[4]=datenew[1];
currentdate[5]=datenew[2];
currentdate[6]=datenew[3];
currentdate[7]=datenew[4];
size=sizeof(currentdate);
s.assign(currentdate,size);
return s;
}
I keep getting a datenew is corrupted error. Why does this happen?