preserve time and date when copying files ubuntu

C++
cp -p oldfile newfile

Source

Also in C++: