各位大历害,我是小学生
正在学C++;
谁能告诉我在C++里怎末求int变量长度
求
急!
int x;
sizeof(x) 返回x所占内存字节数
一个整数的长度
int x=12345;
int len=0,y=x;
while(y>0)
{
y/=10;
len++;
}
cout<< len;
int GetLength(const int tmp)
{
int count=0;
while( tmp/10 )
count++;
return count;
}
to_string(x).size()