I think that before you try doing screen graphics, you should go back to square one on writing C++ code. What you have stands no chance of compiling, much less doing what you think you want it to do.
Just looking at your very first function
int random_x_unit(x)
{
rand() % 640 + 1 = x;
ofstream a_file ("x_coor.dat");
a_file( x, ios::app );
a_file.close();
return(x)'
}; Line 3 - remember that assignment is from the Right Hand Side to the Left Hand side, or LHS <- RHS
Line 6 - does nothing. If you meant to open the file x_coor.dat in append mode, the ios::app needs to be in line 5. To write the value of x to the file, try a_file << x;
Line 7 - a correct statement!
Line 9 - end with a semicolon, not single-quote.
Line 10 - no semicolon needed to close function definition. It probably does no harm, as it's an empty statement.
In your spawn_human( ) function, you call this function above, passing it an unitialized argument, returning the random generated value. You don't store the returned value, but your program assumes that it's x now has some value. So, the number generated by this function is lost. You can transmit it to the caller by value or by reference. Pick one. Use it.