#include <iostream>
#include <cstdlib>
main() {
constchar* user = getenv( "USER" );
std::cout << "The current user is " << ( user ? user : "Unknown" ) << std::endl;
}
(Note that getenv() returns a null pointer if the specified environment variable is not set.)
I think what you mean is how to use the C variable filetosave in the system() call. My C is very bad, as I've been spoilt by iostreams and std::string, but the function you want is snprintf, and it is used something like this: