Updated main to a cpp main

Replaces printfs and warning with cout and cerr and other updates