Added cstdlib and replaced Microsoft-only code

- Added C standard libraries needed to compile on Linux
- Replaced Microsoft-only sprintf_s with multi-platform snprintf