Hello Baps,
What would be the equivalent to std::cout << std::fixed << std::showpoint << std::setprecision(2); for me? |
Actually this is the equaliviant of your printf statements. The format specifiers in the printf take care of how the numbers are printed. "fixed" means to use regular numbers not scientific notation. "showpoint" means to show zero(s) to the right of the decimal point. And "setpercision" says how any numbers there are to the right of the decimal point.
Here is what I'm looking at now. I'm getting lots of errors regarding static_cast and size_t. Are these normal variables in c?
|
No these are C++ standard names. "static_cast" may even be C++11 standards I am not sure. "size_t" may be a C++ name and it is just another name for "unsigned int".
My compiler is set to use the C++11 standards and that is why it does not give me any errors or warnings.
Your compiler may not be set for the C++11 standards or it might be an older compiler for C programs.
For line 12 you could use
srand((unsigned int)(time(0));
. It has been awhile, but I believe this is the C way of type casting a variable or in this cas a return value.
I do not know what your compiler is or how it is set up, but it might not hurt to see if the is a newer version the would at least use the 2011 standards.
BTW even your original program with the change to line 12 compiled and ran fine for me.
Hope that helps,
Andy