#include <iostream>
using namespace std;
int main()
{
int i;
float x, y, z;
double d;
i = 15;
d = 40;
x = 25;
y = 125;
z = y/x;
return 0;
}
Question to all .. I need to declare the size of my int, float(s), and the double listed above. How would I got about doing so?
For instance, my string: string str ("str");
I did it like: cout << "The size of my str is: " << str.size() << " characters." << endl;
Please help!
If you are talking about the size in bytes you can use sizeof. This is very different from what you get from the size() member function.
Last edited on
There is no such a standard fucntion that would report the number of decimal digits. You can write it yourself.:)
For example if you are using MS VC++ 2010 you can write
1 2 3 4
|
double f = 6.25;
std::string s = std::to_string( ( long double )f );
std::cout << "s = " << s << ", size = " << s.size() << std::endl;
|
The result is
Last edited on